Daniel Peñalba
Daniel Peñalba

Reputation: 31847

Can I differentiate a Slack display name from a Slack ID?

I'm integrating my software with the Slack API, and I would like to allow the user to configure the Slack settings by writing either the "display name" or the "user ID".

I would like to use an heuristic to differentiate user names from user ids. I read the following in the Slack documentation:

id - this user's ID, which might start with U or W; IDs beginning with U are unique only to a workspace. IDs beginning with W are unique for an entire Enterprise Grid organization and may represent the user on multiple workspaces within it.

Taking a look to a Slack ID, for example (W012A3CDE), it seems that it fits the following specs:

If all above are true, I would not be difficult to differentiate the user name from id, and even in an ambiguity case, I would allow to use @ to resolve the ambiguity.

So my question is: Is there any public spec about how Slack user IDs are?

Upvotes: 2

Views: 1002

Answers (1)

Daniel Peñalba
Daniel Peñalba

Reputation: 31847

Well, I finally found the public Slack regexp used for the user ID:

https://github.com/slackapi/slack-api-specs/blob/master/web-api/slack_web_openapi_v2.json#L106

    "defs_user_id": {
        "pattern": "^[UW][A-Z0-9]{8}$",
        "title": "User ID",
        "type": "string"
    },

Upvotes: 4

Related Questions