docs/versioned_docs/version-1.12.0/00300-resources/00200-reference/00200-http-api/00200-identity.md
/v1/identityThe HTTP endpoints in /v1/identity allow clients to generate and manage Spacetime public identities and private tokens.
| Route | Description |
|---|---|
POST /v1/identity | Generate a new identity and token. |
POST /v1/identity/websocket-token | Generate a short-lived access token for use in untrusted contexts. |
GET /v1/identity/public-key | Get the public key used for verifying tokens. |
GET /v1/identity/:identity/databases | List databases owned by an identity. |
GET /v1/identity/:identity/verify | Verify an identity and token. |
POST /v1/identityCreate a new identity.
Returns JSON in the form:
{
"identity": string,
"token": string
}
POST /v1/identity/websocket-tokenGenerate a short-lived access token which can be used in untrusted contexts, e.g. embedded in URLs.
| Name | Value |
|---|---|
Authorization | A Spacetime token encoded as Basic authorization. |
Returns JSON in the form:
{
"token": string
}
The token value is a short-lived JSON Web Token.
GET /v1/identity/public-keyFetches the public key used by the database to verify tokens.
Returns a response of content-type application/pem-certificate-chain.
POST /v1/identity/:identity/set-emailAssociate an email with a Spacetime identity.
| Name | Value |
|---|---|
:identity | The identity to associate with the email. |
| Name | Value |
|---|---|
email | An email address. |
| Name | Value |
|---|---|
Authorization | A Spacetime token encoded as Basic authorization. |
GET /v1/identity/:identity/databasesList all databases owned by an identity.
| Name | Value |
|---|---|
:identity | A Spacetime identity. |
Returns JSON in the form:
{
"addresses": array<string>
}
The addresses value is an array of zero or more strings, each of which is the address of a database owned by the identity passed as a parameter.
GET /v1/identity/:identity/verifyVerify the validity of an identity/token pair.
| Name | Value |
|---|---|
:identity | The identity to verify. |
| Name | Value |
|---|---|
Authorization | A Spacetime token encoded as Basic authorization. |
Returns no data.
If the token is valid and matches the identity, returns 204 No Content.
If the token is valid but does not match the identity, returns 400 Bad Request.
If the token is invalid, or no Authorization header is included in the request, returns 401 Unauthorized.