Create token
Description
Create a new token.
Note that a token is created automatically when you create a collection. So you don’t need to call this method, until you want several tokens.
Url
1 |
POST /api/v0/token/ |
Parameters
optional
- collection: resource uri like /v0/collection/UUID/
Example
Create a token for the collection whose UUID is 806e54535ffd464f83545c902e664aca
Request
1 2 3 4 |
curl -X POST \ -H "Content-Type: application/json" \ 'https://my.craftar.net/api/v0/token/?api_key=123456789abcdefghijk123456789abcdefghijk' \ -d '{"collection": "/api/v0/collection/806e54535ffd464f83545c902e664aca/" }' |
Response
HTTP Status code: 201 Created
1 2 3 4 5 |
{ "token": "67e857fbb70642dd", "resource_uri": "/api/v0/token/67e857fbb70642dd/", "collection": "/api/v0/collection/806e54535ffd464f83545c902e664aca/" } |
Errors
HTTP Status code: 400 Bad Request
Invalid JSON
1 2 3 4 5 6 |
{ "error": { "message": "The content is not a valid JSON document.", "code": "INVALID_JSON" } } |
Content not in JSON
1 2 3 4 5 6 |
{ "error": { "message": "Expected application/json content but got application/xml.", "code": "WRONG_CONTENT_TYPE" } } |
Invalid collection
1 2 3 4 5 6 7 8 9 |
{ "error": { "code": "VALIDATION_ERROR", "message": "Some of the provided fields couldn't be validated. See the 'details' key for more information.", "details": { "collection": ["This field is required."] } } } |