Create an Access Token
POST /v1/access_tokens
Create a new access token for the user performing the request.
Request Parameters
Location | Data Item | Type | Required/ Optional | Description |
---|---|---|---|---|
body | data |
object | required | |
body | data.type |
string | required | The type of data (access_tokens in this case). |
body | data.attributes |
object | optional | |
body | data.attributes.display_name |
string | optional | A human-readable name to assign to this access token, to allow for easier identification. If not provided, defaults to an empty string. |
Example Request
Header
POST /v1/access_tokens HTTP/1.1
Host: api.ampermusic.com
Content-Type: application/vnd.api+json
Authorization: Basic abcxyz
Body
{
"data": {
"type": "access_tokens",
"attributes": {
"display_name": "Token for my very first app"
}
}
}
Response Data
Location | Data Item | Type | Description |
---|---|---|---|
body | data |
object | |
body | data.type |
string | The type of data (access_tokens in this case). |
body | data.id |
string | The permanent ID of this access token. |
body | data.attributes |
object | |
body | data.attributes.access_token_plaintext |
string | The full secret token. This value will only be returned once. After that, it can never be retrieved again by anybody. |
body | data.attributes.access_token_redacted |
string | A short, redacted snippet of the beginning of the secret token. |
body | data.attributes.display_name |
string | A human-readable name for this access token, to allow for easier identification. |
body | data.attributes.date_create |
string | The date when this access token was created. |
body | data.attributes.date_access |
string | The date when this access token was last used to perform any API request. |
body | data.links |
object | |
body | data.links.self |
string | The token URL. |
Note: All dates are formatted as ISO-8601 date and time strings. For example,
2018-08-08T08:08:08+00:00
.
Example Response
Header
HTTP/1.1 201 Created
Content-Type: application/vnd.api+json
ETag: W/"bbc6f6ebcfff5c94258db3ddfe0b9b6a5ddca909"
Location: /v1/access_tokens/abcd1234
Body
{
"data": {
"type": "access_tokens",
"id": "abcd1234",
"attributes": {
"access_token_plaintext": "abcd1234EFGH5678ijkl9012MNOP3456abcd1234EFGH5678ijkl9012MNOP3456",
"access_token_redacted": "abcd1234***",
"display_name": "Token for my very first app",
"date_create": "2018-10-04T00:00:00.000000+00:00",
"date_access": null
},
"links": {
"self": "https://api.ampermusic.com/v1/access_tokens/abcd1234"
}
},
"links": {
"self": "https://api.ampermusic.com/v1/access_tokens/abcd1234"
}
}
POST /v1/users/{id}/access_tokens
Create a new access token for the user specified in the URL path.
The user performing this request must be an admin, and the user ID in the path must belong to the admin’s account.
All request and response parameters are the same as above, with the following addition:
Request Parameters
Location | Data Item | Type | Required/ Optional | Description |
---|---|---|---|---|
path | id |
string | required | The ID of the user this access token should be created for. |