Identity Service API

The Matrix client-server and server-server APIs are largely expressed in Matrix user identifiers. From time to time, it is useful to refer to users by other ("third-party") identifiers, or "3pid"s, e.g. their email address or phone number. This Identity Service Specification describes how mappings between third-party identifiers and Matrix user identifiers can be established, validated, and used. This description technically may apply to any 3pid, but in practice has only been applied specifically to email addresses and phone numbers.

1   Changelog

Version: r0.1.0

No significant changes.

This version of the specification is generated from matrix-doc as of Git commit identity_service/release-r0.1.0,10fa5a3a.

For the full historical changelog, see https://github.com/matrix-org/matrix-doc/blob/master/changelogs/identity_service.rst

1.1   Other versions of this specification

The following other versions are also available, in reverse chronological order:

  • HEAD: Includes all changes since the latest versioned release.

2   General principles

The purpose of an identity server is to validate, store, and answer questions about the identities of users. In particular, it stores associations of the form "identifier X represents the same user as identifier Y", where identities may exist on different systems (such as email addresses, phone numbers, Matrix user IDs, etc).

The identity server has some private-public keypairs. When asked about an association, it will sign details of the association with its private key. Clients may validate the assertions about associations by verifying the signature with the public key of the identity server.

In general, identity servers are treated as reliable oracles. They do not necessarily provide evidence that they have validated associations, but claim to have done so. Establishing the trustworthiness of an individual identity server is left as an exercise for the client.

3PID types are described in 3PID Types Appendix.

3   API standards

The mandatory baseline for identity server communication in Matrix is exchanging JSON objects over HTTP APIs. HTTPS is required for communication, and all API calls use a Content-Type of application/json. In addition, strings MUST be encoded as UTF-8.

Any errors which occur at the Matrix API level MUST return a "standard error response". This is a JSON object which looks like:

{
  "errcode": "<error code>",
  "error": "<error message>"
}

The error string will be a human-readable error message, usually a sentence explaining what went wrong. The errcode string will be a unique string which can be used to handle an error message e.g. M_FORBIDDEN. There may be additional keys depending on the error, but the keys error and errcode MUST always be present.

Some standard error codes are below:

M_NOT_FOUND:The resource requested could not be located.
M_MISSING_PARAMS:
 The request was missing one or more parameters.
M_INVALID_PARAM:
 The request contained one or more invalid parameters.
M_SESSION_NOT_VALIDATED:
 The session has not been validated.
M_NO_VALID_SESSION:
 A session could not be located for the given parameters.
M_SESSION_EXPIRED:
 The session has expired and must be renewed.
M_INVALID_EMAIL:
 The email address provided was not valid.
M_EMAIL_SEND_ERROR:
 There was an error sending an email. Typically seen when attempting to verify ownership of a given email address.
M_INVALID_ADDRESS:
 The provided third party address was not valid.
M_SEND_ERROR:There was an error sending a notification. Typically seen when attempting to verify ownership of a given third party address.
M_UNRECOGNIZED:The request contained an unrecognised value, such as an unknown token or medium.
M_THREEPID_IN_USE:
 The third party identifier is already in use by another user. Typically this error will have an additional mxid property to indicate who owns the third party identifier.
M_UNKNOWN:An unknown error has occurred.

4   Privacy

Identity is a privacy-sensitive issue. While the identity server exists to provide identity information, access should be restricted to avoid leaking potentially sensitive data. In particular, being able to construct large-scale connections between identities should be avoided. To this end, in general APIs should allow a 3pid to be mapped to a Matrix user identity, but not in the other direction (i.e. one should not be able to get all 3pids associated with a Matrix user ID, or get all 3pids associated with a 3pid).

5   Web browser clients

It is realistic to expect that some clients will be written to be run within a web browser or similar environment. In these cases, the identity server should respond to pre-flight requests and supply Cross-Origin Resource Sharing (CORS) headers on all requests.

When a client approaches the server with a pre-flight (OPTIONS) request, the server should respond with the CORS headers for that route. The recommended CORS headers to be returned by servers on all requests are:

Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization

6   Status check

6.1   GET /_matrix/identity/api/v1

Checks that an identity server is available at this API endpoint.

To discover that an identity server is available at a specific URL, this endpoint can be queried and will return an empty object.

This is primarly used for auto-discovery and health check purposes by entities acting as a client for the identity server.

Request format:

No parameters

Example request:

GET /_matrix/identity/api/v1 HTTP/1.1

Response:

Status code 200:

An identity server is ready to serve requests.

Example

{}

7   Key management

An identity server has some long-term public-private keypairs. These are named in a scheme algorithm:identifier, e.g. ed25519:0. When signing an association, the standard Signing JSON algorithm applies.

The identity server may also keep track of some short-term public-private keypairs, which may have different usage and lifetime characteristics than the service's long-term keys.

7.1   GET /_matrix/identity/api/v1/pubkey/{keyId}

Get the public key for the passed key ID.

Request format:

Parameter Type Description
path parameters
keyId string Required. The ID of the key. This should take the form algorithm:identifier where algorithm identifies the signing algorithm, and the identifier is an opaque string.

Response format:

Parameter Type Description
public_key string Required. Unpadded Base64 encoded public key.

Example request:

GET /_matrix/identity/api/v1/pubkey/ed25519%3A0 HTTP/1.1

Responses:

Status code 200:

The public key exists.

Example

{
  "public_key": "VXuGitF39UH5iRfvbIknlvlAVKgD1BsLDMvBf0pmp7c"
}

Status code 404:

The public key was not found.

Example

{
  "errcode": "M_NOT_FOUND",
  "error": "The public key was not found"
}

7.2   GET /_matrix/identity/api/v1/pubkey/isvalid

Check whether a long-term public key is valid. The response should always be the same, provided the key exists.

Request format:

Parameter Type Description
query parameters
public_key string Required. The unpadded base64-encoded public key to check.

Response format:

Parameter Type Description
valid boolean Required. Whether the public key is recognised and is currently valid.

Example request:

GET /_matrix/identity/api/v1/pubkey/isvalid?public_key=VXuGitF39UH5iRfvbIknlvlAVKgD1BsLDMvBf0pmp7c HTTP/1.1

Response:

Status code 200:

The validity of the public key.

Example

{
  "valid": true
}

7.3   GET /_matrix/identity/api/v1/pubkey/ephemeral/isvalid

Check whether a short-term public key is valid.

Request format:

Parameter Type Description
query parameters
public_key string Required. The unpadded base64-encoded public key to check.

Response format:

Parameter Type Description
valid boolean Required. Whether the public key is recognised and is currently valid.

Example request:

GET /_matrix/identity/api/v1/pubkey/ephemeral/isvalid?public_key=VXuGitF39UH5iRfvbIknlvlAVKgD1BsLDMvBf0pmp7c HTTP/1.1

Response:

Status code 200:

The validity of the public key.

Example

{
  "valid": true
}

8   Association lookup

8.1   GET /_matrix/identity/api/v1/lookup

Look up the Matrix user ID for a 3pid.

Request format:

Parameter Type Description
query parameters
medium string Required. The medium type of the 3pid. See the 3PID Types Appendix.
address string Required. The address of the 3pid being looked up. See the 3PID Types Appendix.

Response format:

Parameter Type Description
address string Required. The 3pid address of the user being looked up, matching the address requested.
medium string Required. A medium from the 3PID Types Appendix, matching the medium requested.
mxid string Required. The Matrix user ID associated with the 3pid.
not_before integer Required. A unix timestamp before which the association is not known to be valid.
not_after integer Required. A unix timestamp after which the association is not known to be valid.
ts integer Required. The unix timestamp at which the association was verified.
signatures {string: {string: string}} Required. The signatures of the verifying identity servers which show that the association should be trusted, if you trust the verifying identity servers.

Example request:

GET /_matrix/identity/api/v1/lookup?medium=email&address=louise%40bobs.burgers HTTP/1.1

Response:

Status code 200:

The association for that 3pid, or an empty object if no association is known.

Example

{
  "address": "louise@bobs.burgers",
  "medium": "email",
  "mxid": "@ears:matrix.org",
  "not_before": 1428825849161,
  "not_after": 4582425849161,
  "ts": 1428825849161,
  "signatures": {
    "matrix.org": {
      "ed25519:0": "ENiU2YORYUJgE6WBMitU0mppbQjidDLanAusj8XS2nVRHPu+0t42OKA/r6zV6i2MzUbNQ3c3MiLScJuSsOiVDQ"
    }
  }
}

8.2   POST /_matrix/identity/api/v1/bulk_lookup

Lookup Matrix user IDs for a list of 3pids.

Request format:

Parameter Type Description
JSON body parameters
threepids [[string, string]] Required. An array of arrays containing the 3PID Types with the medium in first position and the address in second position.

Response format:

Parameter Type Description
threepids [[string, string, string]] Required. An array of array containing the 3PID Types with the medium in first position, the address in second position and Matrix user ID in third position.

Example request:

POST /_matrix/identity/api/v1/bulk_lookup HTTP/1.1
Content-Type: application/json

{
  "threepids": [
    [
      "email",
      "user@example.org"
    ],
    [
      "msisdn",
      "123456789"
    ],
    [
      "email",
      "user2@example.org"
    ]
  ]
}

Response:

Status code 200:

A list of known 3PID mappings for the supplied 3PIDs.

Example

{
  "threepids": [
    [
      "email",
      "user@example.org",
      "@bla:example.org"
    ],
    [
      "msisdn",
      "123456789",
      "@blah2:example.com"
    ]
  ]
}

9   Establishing associations

The flow for creating an association is session-based.

Within a session, one may prove that one has ownership of a 3pid. Once this has been established, the user can form an association between that 3pid and a Matrix user ID. Note that this association is only proved one way; a user can associate any Matrix user ID with a validated 3pid, i.e. I can claim that any email address I own is associated with @billg:microsoft.com.

Sessions are time-limited; a session is considered to have been modified when it was created, and then when a validation is performed within it. A session can only be checked for validation, and validation can only be performed within a session, within a 24 hour period since its most recent modification. Any attempts to perform these actions after the expiry will be rejected, and a new session should be created and used instead.

To start a session, the client makes a request to the appropriate /requestToken endpoint. The identity server then sends a validation token to the user, and the user provides the token to the client. The client then provides the token to the appropriate /submitToken endpoint, completing the session. At this point, the client should /bind the third party identifier or leave it for another entity to bind.

9.1   Format of a validation token

The format of the validation token is left up to the identity server: it should choose one appropriate to the 3PID type. (For example, it would be inappropriate to expect a user to copy a long passphrase including punctuation from an SMS message into a client.)

Whatever format the identity server uses, the validation token must consist of at most 255 Unicode codepoints. Clients must pass the token through without modification.

9.2   Email associations

9.2.1   POST /_matrix/identity/api/v1/validate/email/requestToken

Create a session for validating an email address.

The identity server will send an email containing a token. If that token is presented to the identity server in the future, it indicates that that user was able to read the email for that email address, and so we validate ownership of the email address.

Note that homeservers offer APIs that proxy this API, adding additional behaviour on top, for example, /register/email/requestToken is designed specifically for use when registering an account and therefore will inform the user if the email address given is already registered on the server.

Note: for backwards compatibility with previous drafts of this specification, the parameters may also be specified as application/x-form-www-urlencoded data. However, this usage is deprecated.

Request format:

Parameter Type Description
JSON body parameters
client_secret string Required. A unique string generated by the client, and used to identify the validation attempt. It must be a string consisting of the characters [0-9a-zA-Z.=_-]. Its length must not exceed 255 characters and it must not be empty.
email string Required. The email address to validate.
send_attempt integer Required. The server will only send an email if the send_attempt is a number greater than the most recent one which it has seen, scoped to that email + client_secret pair. This is to avoid repeatedly sending the same email in the case of request retries between the POSTing user and the identity server. The client should increment this value if they desire a new email (e.g. a reminder) to be sent.
next_link string Optional. When the validation is completed, the identity server will redirect the user to this URL.

Response format:

Parameter Type Description
sid string Required. The session ID. Session IDs are opaque strings generated by the identity server. They must consist entirely of the characters [0-9a-zA-Z.=_-]. Their length must not exceed 255 characters and they must not be empty.

Example request:

POST /_matrix/identity/api/v1/validate/email/requestToken HTTP/1.1
Content-Type: application/json

{
  "client_secret": "monkeys_are_GREAT",
  "email": "foo@example.com",
  "send_attempt": 1
}

Responses:

Status code 200:

Session created.

Example

{
  "sid": "123abc"
}

Status code 400:

An error ocurred. Some possible errors are:

  • M_INVALID_EMAIL: The email address provided was invalid.
  • M_EMAIL_SEND_ERROR: The validation email could not be sent.

Example

{
  "errcode": "M_INVALID_EMAIL",
  "error": "The email address is not valid"
}

9.2.2   POST /_matrix/identity/api/v1/validate/email/submitToken

Validate ownership of an email address.

If the three parameters are consistent with a set generated by a requestToken call, ownership of the email address is considered to have been validated. This does not publish any information publicly, or associate the email address with any Matrix user ID. Specifically, calls to /lookup will not show a binding.

The identity server is free to match the token case-insensitively, or carry out other mapping operations such as unicode normalisation. Whether to do so is an implementation detail for the identity server. Clients must always pass on the token without modification.

Note: for backwards compatibility with previous drafts of this specification, the parameters may also be specified as application/x-form-www-urlencoded data. However, this usage is deprecated.

Request format:

Parameter Type Description
JSON body parameters
sid string Required. The session ID, generated by the requestToken call.
client_secret string Required. The client secret that was supplied to the requestToken call.
token string Required. The token generated by the requestToken call and emailed to the user.

Response format:

Parameter Type Description
success boolean Required. Whether the validation was successful or not.

Example request:

POST /_matrix/identity/api/v1/validate/email/submitToken HTTP/1.1
Content-Type: application/json

{
  "sid": "1234",
  "client_secret": "monkeys_are_GREAT",
  "token": "atoken"
}

Response:

Status code 200:

The success of the validation.

Example

{
  "success": true
}

9.2.3   GET /_matrix/identity/api/v1/validate/email/submitToken

Validate ownership of an email address.

If the three parameters are consistent with a set generated by a requestToken call, ownership of the email address is considered to have been validated. This does not publish any information publicly, or associate the email address with any Matrix user ID. Specifically, calls to /lookup will not show a binding.

Note that, in contrast with the POST version, this endpoint will be used by end-users, and so the response should be human-readable.

Request format:

Parameter Type Description
query parameters
sid string Required. The session ID, generated by the requestToken call.
client_secret string Required. The client secret that was supplied to the requestToken call.
token string Required. The token generated by the requestToken call and emailed to the user.

Example request:

GET /_matrix/identity/api/v1/validate/email/submitToken?sid=1234&client_secret=monkeys_are_GREAT&token=atoken HTTP/1.1

Responses:

Status code 200:

Email address is validated.

Status code 3xx:

Email address is validated, and the next_link parameter was provided to the requestToken call. The user must be redirected to the URL provided by the next_link parameter.

Status code 4xx:

Validation failed.

9.3   Phone number associations

9.3.1   POST /_matrix/identity/api/v1/validate/msisdn/requestToken

Create a session for validating a phone number.

The identity server will send an SMS message containing a token. If that token is presented to the identity server in the future, it indicates that that user was able to read the SMS for that phone number, and so we validate ownership of the phone number.

Note that homeservers offer APIs that proxy this API, adding additional behaviour on top, for example, /register/msisdn/requestToken is designed specifically for use when registering an account and therefore will inform the user if the phone number given is already registered on the server.

Note: for backwards compatibility with previous drafts of this specification, the parameters may also be specified as application/x-form-www-urlencoded data. However, this usage is deprecated.

Request format:

Parameter Type Description
JSON body parameters
client_secret string Required. A unique string generated by the client, and used to identify the validation attempt. It must be a string consisting of the characters [0-9a-zA-Z.=_-]. Its length must not exceed 255 characters and it must not be empty.
country string Required. The two-letter uppercase ISO country code that the number in phone_number should be parsed as if it were dialled from.
phone_number string Required. The phone number to validate.
send_attempt integer Required. The server will only send an SMS if the send_attempt is a number greater than the most recent one which it has seen, scoped to that country + phone_number + client_secret triple. This is to avoid repeatedly sending the same SMS in the case of request retries between the POSTing user and the identity server. The client should increment this value if they desire a new SMS (e.g. a reminder) to be sent.
next_link string Optional. When the validation is completed, the identity server will redirect the user to this URL.

Response format:

Parameter Type Description
sid string Required. The session ID. Session IDs are opaque strings generated by the identity server. They must consist entirely of the characters [0-9a-zA-Z.=_-]. Their length must not exceed 255 characters and they must not be empty.

Example request:

POST /_matrix/identity/api/v1/validate/msisdn/requestToken HTTP/1.1
Content-Type: application/json

{
  "client_secret": "monkeys_are_GREAT",
  "country": "GB",
  "phone_number": "07700900001",
  "send_attempt": 1
}

Responses:

Status code 200:

Session created.

Example

{
  "sid": "123abc"
}

Status code 400:

An error ocurred. Some possible errors are:

  • M_INVALID_ADDRESS: The phone number provided was invalid.
  • M_SEND_ERROR: The validation SMS could not be sent.
  • M_DESTINATION_REJECTED: The identity server cannot deliver an SMS to the provided country or region.

Example

{
  "errcode": "M_INVALID_ADDRESS",
  "error": "The phone number is not valid"
}

9.3.2   POST /_matrix/identity/api/v1/validate/msisdn/submitToken

Validate ownership of a phone number.

If the three parameters are consistent with a set generated by a requestToken call, ownership of the phone number is considered to have been validated. This does not publish any information publicly, or associate the phone number address with any Matrix user ID. Specifically, calls to /lookup will not show a binding.

The identity server is free to match the token case-insensitively, or carry out other mapping operations such as unicode normalisation. Whether to do so is an implementation detail for the identity server. Clients must always pass on the token without modification.

Note: for backwards compatibility with previous drafts of this specification, the parameters may also be specified as application/x-form-www-urlencoded data. However, this usage is deprecated.

Request format:

Parameter Type Description
JSON body parameters
sid string Required. The session ID, generated by the requestToken call.
client_secret string Required. The client secret that was supplied to the requestToken call.
token string Required. The token generated by the requestToken call and sent to the user.

Response format:

Parameter Type Description
success boolean Required. Whether the validation was successful or not.

Example request:

POST /_matrix/identity/api/v1/validate/msisdn/submitToken HTTP/1.1
Content-Type: application/json

{
  "sid": "1234",
  "client_secret": "monkeys_are_GREAT",
  "token": "atoken"
}

Response:

Status code 200:

The success of the validation.

Example

{
  "success": true
}

9.3.3   GET /_matrix/identity/api/v1/validate/msisdn/submitToken

Validate ownership of a phone number.

If the three parameters are consistent with a set generated by a requestToken call, ownership of the phone number address is considered to have been validated. This does not publish any information publicly, or associate the phone number with any Matrix user ID. Specifically, calls to /lookup will not show a binding.

Note that, in contrast with the POST version, this endpoint will be used by end-users, and so the response should be human-readable.

Request format:

Parameter Type Description
query parameters
sid string Required. The session ID, generated by the requestToken call.
client_secret string Required. The client secret that was supplied to the requestToken call.
token string Required. The token generated by the requestToken call and sent to the user.

Example request:

GET /_matrix/identity/api/v1/validate/msisdn/submitToken?sid=1234&client_secret=monkeys_are_GREAT&token=atoken HTTP/1.1

Responses:

Status code 200:

Phone number is validated.

Status code 3xx:

Phone number address is validated, and the next_link parameter was provided to the requestToken call. The user must be redirected to the URL provided by the next_link parameter.

Status code 4xx:

Validation failed.

9.4   General

9.4.1   GET /_matrix/identity/api/v1/3pid/getValidated3pid

Determines if a given 3pid has been validated by a user.

Request format:

Parameter Type Description
query parameters
sid string Required. The Session ID generated by the requestToken call.
client_secret string Required. The client secret passed to the requestToken call.

Response format:

Parameter Type Description
medium string Required. The medium type of the 3pid.
address string Required. The address of the 3pid being looked up.
validated_at integer Required. Timestamp, in milliseconds, indicating the time that the 3pid was validated.

Example request:

GET /_matrix/identity/api/v1/3pid/getValidated3pid?sid=1234&client_secret=monkeys_are_GREAT HTTP/1.1

Responses:

Status code 200:

Validation information for the session.

Example

{
  "medium": "email",
  "validated_at": 1457622739026,
  "address": "louise@bobs.burgers"
}

Status code 400:

The session has not been validated.

If the session has not been validated, then errcode will be M_SESSION_NOT_VALIDATED. If the session has timed out, then errcode will be M_SESSION_EXPIRED.

Example

{
  "errcode": "M_SESSION_NOT_VALIDATED",
  "error": "This validation session has not yet been completed"
}

Status code 404:

The Session ID or client secret were not found.

Example

{
  "errcode": "M_NO_VALID_SESSION",
  "error": "No valid session was found matching that sid and client secret"
}

9.4.2   POST /_matrix/identity/api/v1/bind

Publish an association between a session and a Matrix user ID.

Future calls to /lookup for any of the session's 3pids will return this association.

Note: for backwards compatibility with previous drafts of this specification, the parameters may also be specified as application/x-form-www-urlencoded data. However, this usage is deprecated.

Request format:

Parameter Type Description
JSON body parameters
sid string Required. The Session ID generated by the requestToken call.
client_secret string Required. The client secret passed to the requestToken call.
mxid string Required. The Matrix user ID to associate with the 3pids.

Response format:

Parameter Type Description
address string Required. The 3pid address of the user being looked up.
medium string Required. The medium type of the 3pid.
mxid string Required. The Matrix user ID associated with the 3pid.
not_before integer Required. A unix timestamp before which the association is not known to be valid.
not_after integer Required. A unix timestamp after which the association is not known to be valid.
ts integer Required. The unix timestamp at which the association was verified.
signatures {string: {string: string}} Required. The signatures of the verifying identity servers which show that the association should be trusted, if you trust the verifying identity services.

Example request:

POST /_matrix/identity/api/v1/bind HTTP/1.1
Content-Type: application/json

{
  "sid": "1234",
  "client_secret": "monkeys_are_GREAT",
  "mxid": "@ears:matrix.org"
}

Responses:

Status code 200:

The association was published.

Example

{
  "address": "louise@bobs.burgers",
  "medium": "email",
  "mxid": "@ears:matrix.org",
  "not_before": 1428825849161,
  "not_after": 4582425849161,
  "ts": 1428825849161,
  "signatures": {
    "matrix.org": {
      "ed25519:0": "ENiU2YORYUJgE6WBMitU0mppbQjidDLanAusj8XS2nVRHPu+0t42OKA/r6zV6i2MzUbNQ3c3MiLScJuSsOiVDQ"
    }
  }
}

Status code 400:

The association was not published.

If the session has not been validated, then errcode will be M_SESSION_NOT_VALIDATED. If the session has timed out, then errcode will be M_SESSION_EXPIRED.

Example

{
  "errcode": "M_SESSION_NOT_VALIDATED",
  "error": "This validation session has not yet been completed"
}

Status code 404:

The Session ID or client secret were not found

Example

{
  "errcode": "M_NO_VALID_SESSION",
  "error": "No valid session was found matching that sid and client secret"
}

10   Invitation storage

An identity server can store pending invitations to a user's 3pid, which will be retrieved and can be either notified on or look up when the 3pid is associated with a Matrix user ID.

At a later point, if the owner of that particular 3pid binds it with a Matrix user ID, the identity server will attempt to make an HTTP POST to the Matrix user's homeserver via the /3pid/onbind endpoint. The request MUST be signed with a long-term private key for the identity server.

10.1   POST /_matrix/identity/api/v1/store-invite

Store pending invitations to a user's 3pid.

In addition to the request parameters specified below, an arbitrary number of other parameters may also be specified. These may be used in the invite message generation described below.

The service will generate a random token and an ephemeral key used for accepting the invite.

The service also generates a display_name for the inviter, which is a redacted version of address which does not leak the full contents of the address.

The service records persistently all of the above information.

It also generates an email containing all of this data, sent to the address parameter, notifying them of the invitation.

Also, the generated ephemeral public key will be listed as valid on requests to /_matrix/identity/api/v1/pubkey/ephemeral/isvalid.

Currently, invites may only be issued for 3pids of the email medium.

Request format:

Parameter Type Description
JSON body parameters
medium string Required. The literal string email.
address string Required. The email address of the invited user.
room_id string Required. The Matrix room ID to which the user is invited
sender string Required. The Matrix user ID of the inviting user

Response format:

Parameter Type Description
token string Required. The generated token. Must be a string consisting of the characters [0-9a-zA-Z.=_-]. Its length must not exceed 255 characters and it must not be empty.
public_keys [string] Required. A list of [server's long-term public key, generated ephemeral public key].
display_name string Required. The generated (redacted) display_name.

Example request:

POST /_matrix/identity/api/v1/store-invite HTTP/1.1
Content-Type: application/json

{
  "medium": "email",
  "address": "foo@bar.baz",
  "room_id": "!something:example.tld",
  "sender": "@bob:example.com"
}

Responses:

Status code 200:

The invitation was stored.

Example

{
  "application/json": {
    "token": "sometoken",
    "public_keys": [
      "serverpublickey",
      "ephemeralpublickey"
    ],
    "display_name": "f...@b..."
  }
}

Status code 400:

An error has occured.

If the 3pid is already bound to a Matrix user ID, the error code will be M_THREEPID_IN_USE. If the medium is unsupported, the error code will be M_UNRECOGNIZED.

Example

{
  "errcode": "M_THREEPID_IN_USE",
  "error": "Binding already known",
  "mxid": "@alice:example.com"
}

11   Ephemeral invitation signing

To aid clients who may not be able to perform crypto themselves, the identity server offers some crypto functionality to help in accepting invitations. This is less secure than the client doing it itself, but may be useful where this isn't possible.

11.1   POST /_matrix/identity/api/v1/sign-ed25519

Sign invitation details.

The identity server will look up token which was stored in a call to store-invite, and fetch the sender of the invite.

Request format:

Parameter Type Description
JSON body parameters
mxid string Required. The Matrix user ID of the user accepting the invitation.
token string Required. The token from the call to store- invite.
private_key string Required. The private key, encoded as Unpadded base64.

Response format:

Parameter Type Description
mxid string Required. The Matrix user ID of the user accepting the invitation.
sender string Required. The Matrix user ID of the user who sent the invitation.
signatures {string: {string: string}} Required. The signature of the mxid, sender, and token.
token string Required. The token for the invitation.

Example request:

POST /_matrix/identity/api/v1/sign-ed25519 HTTP/1.1
Content-Type: application/json

{
  "mxid": "@foo:bar.com",
  "token": "sometoken",
  "private_key": "base64encodedkey"
}

Responses:

Status code 200:

The signed JSON of the mxid, sender, and token.

Example

{
  "mxid": "@foo:bar.com",
  "sender": "@baz:bar.com",
  "signatures": {
    "my.id.server": {
      "ed25519:0": "def987"
    }
  },
  "token": "abc123"
}

Status code 404:

The token was not found.

Example

{
  "errcode": "M_UNRECOGNIZED",
  "error": "Didn't recognize token"
}