Create collection
Description
Create a new collection.
Url
1 |
POST /api/v0/collection/ |
Parameters
optional
- name: must be unique
Example
Create a collection named Wine bottles
Request
1 2 3 |
curl -X POST -H "Content-Type: application/json" 'https://my.craftar.net/api/v0/collection/?api_key=123456789abcdefghijk123456789abcdefghijk' -d '{"name": "Wine bottles" }' |
Response
HTTP Status code: 201 Created
1 2 3 4 5 |
{ "uuid": "14776d3099d2434b962b09b22680c408", "resource_uri": "/api/v0/collection/14776d3099d2434b962b09b22680c408/", "name": "Wine bottles" } |
1 |
curl -X POST -H "Content-Type: application/json" 'https://my.craftar.net/api/v0/collection/?api_key=123456789abcdefghijk123456789abcdefghijk' -d '{"name": "Wine bottles" }' |
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" } } |
Duplicate collection name
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": { "name": ["Collection name must be unique"] } } } |
Empty collection name
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": { "name": ["This field is required."] } } } |
HTTP Status code: 403 Forbidden
Collection limit reached
1 2 3 4 5 6 |
{ "error": { "message": "You have reached the limit of collections for your plan. You can upgrade to a bigger plan to increase this limit.", "code": "COLLECTION_QUOTA_EXCEEDED" } } |