How to set path variable in Tyk?


I have an API in Tyk, and it has this listening path like this:


Here, I want to make the {id} as path variable. Is is possible to do it in Tyk?

Like when I call /myapi/1, or /myapi/2, it will proxy to the same URL?



Maan Tarng

@maantarng It is very possible. I think you can either use a golang regex in the listen path.

Or you could use the sub or relative path as described in our endpoint designer documentation.

Hope this helps.

Thanks @Olu.

Do you know is it possible to configure path variable in the proxy URL as well?

Like let’s say I want to proxy to this URL:{id}/status

Is it possible also to make this {id} as a path variable in the proxy URL?


I don’t think this is possible to do in the field itself. However, we have a URL Rewrite feature you could take advantage of. Generating the right capture group based on the match pattern would work for your use case.

In summary a combination of URL Rewrite and regex should do the trick.


Ok. Thanks. I will try that.