Azure Guidelines: Determine appropriate guidance for use of "leader" character for actions
In the proposed update to the Azure REST Guidelines ( #264 ) there is guidance on using the ":" character as a "leader" to indicate that what follows is an action on the resource (See: "Performing an Action"). However, Postman (and other REST clients like the GitHub CLI) treat ":" as path variables.
The main benefit of using a distinct character in the path to distinguish between an action and a “standard REST operation” (i.e. POST-to-create) is that it allows us to distinguish between actions on a collection and an item in a collection. In reality, this is relatively rare – especially since POSTing to an individual resource (as opposed to POSTing to a collection) is not a common requirement. According to this GitHub issue comment, the workaround in Postman is to simply %-encode the colon.
There are a couple of other semi-degenerate situations where the distinct character can also help (user defined names of subcollections + actions), but that is rare. The other benefit is the visual distinguisher for someone looking at the API surface area.
To resolve this issue, we need to determine:
-
Should we maintain a character "leader"
-
If so, which character(s) should be supported? If we choose a "leading character" it should be from the reserved set of delimiters. The two characters under consideration are ":" and "!". Note: Current Azure guidelines recommend using ":". A new character would be an additive change and ":" would still be supported for existing implementations.
-
Should this follow the path segment or be concatenated with the resource? Option 1:
/items/:doSomething?param=foo
Option 2:
/items:doSomething?param=foo
Note: The content above is a consolidation of a number email discussions/threads and is documented here to move the discussion to a forum more durable and transparent than email.
Testing in Postman, "/:" -> ":" does indeed solve the issue of looking like a path variable; however, in swaggers like https://github.com/Azure/azure-rest-api-specs/blob/0e23428515973e7893a9e6364f0e432f1e8adeb5/specification/cognitiveservices/data-plane/Language/preview/2021-05-01-preview/questionanswering.json#L30 , if this was a root path (in this case it's not, since the hostTemplate is "{endpoint}/language"), the URI would still require a leading slash making this again to look like a path parameter. If we're certain that isn't likely - that an action will always be on an item or collection preceding it in the URI - I do like the "/items:doSomething" example.
I originally started the thread because of the minor annoyance of Postman treating this like a variable, but URI-encoding the ":" as "%3A" seems like a suitable workaround rather than diverge from an emerging consistency regarding actions with other REST APIs.
If there is no strong reason to switch away from :, I'd greatly like to keep it as is because we already do have some services that adopted this.
We had a discussion on this and, given that there is a reasonable work around, a downstream cost to change it, and (at present) minimal impact, we are going to continue with the pattern using the ":", e.g. .../items/:doSomething.
This issue has raised its ugly head again so I am reopening.
To help inform this discussion I have done a scan of the azure-rest-api-specs repo to determine how prevalent the use of ":" is currently in Azure paths. I'm going to describe my analysis methodology since I have probably made some assumptions about how this repo is organized and if any of these could materially affect the results I hope folks will point these out.
To inspect all the "paths" for the pattern of interest -- but only the paths -- I extracted just the "path" values from the API documents with this command run at the root of the azure-rest-api-specs repo (master branch, commit hash 259766b85f):
find . -name '*.json' | while read f; do jq -r '.paths // {} | keys[]' $f 2>/dev/null; done > paths
I realize this "double counts" some paths that occur in multiple versions of a API doc, but I think that will be okay.
This produces a paths file with 40435 lines. sort | uniq | wc -l says that there are 8880 unique paths in this file.
To find paths that use ":" as the "action character", I grep'ed the paths file for "/:" -- the result was 36 hits.
The same search on the unique paths yields only 24 hits. Remember that this is out of 8880 unique paths.
So if I have done the analysis correctly, I think it is fair to say that the ":" pattern is not widely used in Azure.
Update
I made another pass -- this time only looking at "stable" API docs.
I found 6238 unique "stable" paths and only 7 contain the "/:" pattern.
Capturing discussion from internal email to the Azure API Review Board:
The current guidelines suggest:
✅ DO pattern your URL like this to perform an action on a resource URL Pattern https://.../
However, we are running into issues applying this pattern to form recognizer (ex. https://{host}/formrecognzier/documentModels/prebuilt:receipt/:analyze). In particular, POSTMAN interprets “:analyze” as a path variable. Thus, if customers were to paste the URL directly into Postman, it would effectively replace “:analyze” with empty string unless customers explicitly workaround this Postman feature.
So far, we have 5+ developers independently run into this issue (SDK, service, component teams), since most people are using Postman. Each time, it takes hours to figure out what is going on. As most of our top customers use Postman as well, we cannot ship with the current design.
Below are a few options: A. No colon • https://{host}/formrecognzier/documentModels/prebuilt:receipt/analyze • https://{host}/formrecognzier/documentModels/build (instead of /:build) • Addresses the Postman issue • “build” action is now ambiguous with “build” as a modelId. B. Remove previous slash • https://{host}/formrecognzier/documentModels/prebuilt:receipt:analyze • https://{host}/formrecognzier/documentModels:build • Addresses the Postman issue • Follows the Google convention for REST Action. • Since current modelId naming convention contains colon, it is difficult to determine where the action starts. C. Option B + Change modelId naming convention to use dash • https://{host}/formrecognzier/documentModels/prebuilt-receipt:analyze • https://{host}/formrecognzier/documentModels:build • Addresses the Postman issue • Follows the Google convention for REST Action. • Less consistent with previous versions which use “prebuilt:receipt” to describe the document type. We currently recommend Option C.
Note: using a query parameter to designate the action has problems:
- it can be difficult to have multiple actions on a resource, since OpenAPI does not allow query parameters in the path,
- this could make RBAC difficult.
I pulled down the latest Postman client (8.9.1) and tested paths with "/:" (Microsoft style) and the bare ":".
It appears that the "/:" (still) exhibits the problem of Postman interpreting this path segment as a path parameter. I used Postman to issue a request to http://192.168.0.26:1234/pets/:feed and caught the request with nc. It showed the URL as GET /pets/.
But the bare ":" does not hit this problem. A request to http://192.168.0.26:1234/pets:feed results in the URL line as GET /pets:feed.
So if we decide that we really want an identifying character and we are willing to forgo the "/", then the bare colon might be a reasonable solution.
A little more info here. Postman does not seem to recognize the OpenAPI standard syntax, {}, for path parameters.

Notice in this screenshot how "feed" is listed as a path parameter but "petName" is not.
What this tells me is that users cannot simply take paths from our documentation and plug them into Postman -- some manipulation is needed, at least in the case where there is a path parameter.
So if we already require users to understand how Postman represents path parameters and manipulate the path accordingly when using Postman, why is it such a stretch to ask them to percent-encode the ":"?
I just found this: https://learning.postman.com/docs/sending-requests/requests/#sending-parameters So, this: thing is clearly part of Postman's design. Unfortunately, they were there first and we have lots of customers that use it (even I used to use it). So, since we don't have many services using our /: yet and because we can change the character to something else without breaking change (since a service can support both characters), I think we should change the character just to reduce customer friction. I think we could use one of these: +, *, ', = or surround the verb with [verb]
Why not just remove the preceding slash like with option C? From the internal discussion it seemed some people were pretty adamant about having the preceding slash but I didn't understand why. There's already an established pattern out there so I wonder why we should be different.
We are proposing that we will go with option C from above, removing the leading "/".
Therefore, actions will look like... https://{host}/formrecognzier/documentModels/prebuilt-receipt:analyze
@bojunehsu -- Would you mind taking a look?
Looks good.
Note that in addition to using colon to specify path variables, Postman also supports the use double curly braces. The following are equivalent.
- https://host/collection/:id/
- https://host/collection/{{id}}/
https://blog.postman.com/10-tips-for-working-with-postman-variables/
Here's a bit of unexpected but welcome news: Postman just release a new client, 8.10, that fixes the problem with path segments starting with ":". Woo hoo!
I tested it and confirmed that it works. It looks like Postman still considers the segment starting with ":" as a path variable, but if you don't assign it a value, it uses simply substitutes the path variable name, which is just what we want.
More details of the fix are in this issue comment.
Thank you Postman!
We decided to go with the ":" separator without the "/". This is consistent with the Google convention and it avoids the issue with Postman.