Content API
The Content API handles everything related to sending and retrieving content requests. This is what is used for both sending jobs for localizing and for creating new content.
Create a new request
PUT https://api.contentor.com/v1/content
Send a new content request for either localization or creation. For details about the format see the article about the format of content requests.
Headers
Authorization: Bearer your-token-here
Content-Type: application/json
Body
{
"language": {
"source": "sv",
"target": "en"
},
"fields": [
{
"id": "body",
"type": "localizable",
"data": "html",
"value": "<p>Denna text kan innehålla <strong>HTML taggar</strong></p>"
}
]
}
Response 200 OK
{
"id": "generated-unique-id",
"state": "pending",
"created": "2016-02-23T09:02:08.22Z",
"fields": [
...
]
}
Response 400 Bad Request
If an invalid content request is sent, either with no data or if data is missing.
{
"state": "invalid",
"errors": [
"..."
]
}
Response 403 Forbidden
If no authorization header is sent or if the header is not on the form
Bearer your-token-here
or if the token is invalid.
Get status for a single request
GET https://api.contentor.com/v1/content/request/:id
Get a single request based on its identifier.
Try to use use the endpoint that returns several requests for synchronization and only use this method when you need to know specific details about a request.
Parameters
Name | Type | Description |
---|---|---|
:id |
string |
Identifier of request |
Headers
Authorization: Bearer your-token-here
Response 200 OK
{
"id": "{id}",
"state": "completed",
"created": "2016-02-23T09:02:08.22Z",
"completed": "2016-02-26T11:05:43.40Z",
"language": {
"source": "sv",
"target": "en"
},
"fields": [
{
"id": "body",
"type": "localizable",
"data": "html",
"value": "<p>This text can contain <strong>HTML tags</strong></p>",
"originalValue": "<p>Denna text kan innehålla <strong>HTML taggar</strong></p>"
}
]
}
Response 403 Forbidden
If no authorization header is sent or if the header is not on the form
Bearer your-token-here
or if the token is invalid.
Query content
GET https://api.contentor.com/v1/content?query=queryData&otherParams
Query for content requests that have been previously sent using an advanced query.
The article synchronizing content requests contains tips about how to build a good synchronization using this endpoint.
Parameters
Name | Type | Description |
---|---|---|
query |
Query | The query to run encoded as JSON |
page |
string |
(optional) Page number to paginate through results |
Query criteria
This endpoint support a lot of properties to help you build queries that match your needs:
created
- Timestamp range for querying the creation date of the content requestcompleted
- Timestamp range for querying the completion date of the content requeststate
- String representing a valid state value, see Content requests for valuessource
- The source of the content request, should beapi
in most cases, but other values are available for imported files and orders created via the customer portal. Check with your developer contact at Contentor for details.language.source
- String representing the source locale of the content requestlanguage.target
- String representing the target locale of the content requestid
- Query on the identifier of a content request
Example: Query for content requests created last week
{
"criteria": [
{
"type": "source",
"criteria": "api"
},
{
"type": "created",
"criteria": "previous-week"
}
]
}
Example: Query for content requests completed since a certain time and sort them in ascending order:
{
"criteria": [
{
"type": "source",
"criteria": "api"
},
{
"type": "completed",
"criteria": {
"from": "dateOfLastSyncHere"
}
}
],
"sortBy": [ "completed" ]
}
Query sortable properties
This endpoint supports sorting on created
and completed
. Put them in the
sortBy
field to control sorting of results:
{
"criteria": ...,
"sortBy": [ "completed:desc" ]
}
Headers
Authorization: Bearer your-token-here
Response 200 OK
{
"page": 1,
"pages": 3,
"total": 23,
"requests": [
{
"id": "generated-unique-id",
"state": "completed",
"created": "2016-02-23T09:02:08.22Z",
"completed": "2016-02-26T11:05:43.40Z",
"language": {
"source": "sv",
"target": "en"
},
"fields": [
{
"id": "body",
"type": "localizable",
"data": "html",
"value": "<p>This text can contain <strong>HTML tags</strong></p>",
"originalValue": "<p>Denna text kan innehålla <strong>HTML taggar</strong></p>"
}
]
},
...
]
}
Response 400 Bad Request
If any of the parameters are invalid.
Response 403 Forbidden
If no authorization header is sent or if the header is not on the form
Bearer your-token-here
or if the token is invalid.
Set state after import
PUT https://api.contentor.com/v1/content/:id/import
Set state of the imported request after it has been handled. Set this after the imported content have been received and handled. This will make finding eventual errors easier.
Body
{
"importState": "success"
}
Parameters
Name | Type | Description |
---|---|---|
:id |
string |
Identifier of request |
importState |
enum |
The status of the handled content. Can be success or fail . |
Headers
Authorization: Bearer your-token-here
Response 200 OK
{
"id": "{id}",
"importResponse": {
"importState": "success",
"time": "2019-03-18T07:43:13.487Z"
},
...
}
Response 403 Forbidden
If no authorization header is sent or if the header is not on the form
Bearer your-token-here
or if the token is invalid.
Response 404 Not found
If the :id
request does not exist.
Query content (legacy)
GET https://api.contentor.com/v1/content?params
Query for content requests that have been previously sent, optionally limiting the returned requests based on state and completion date.
Parameters
Name | Type | Description |
---|---|---|
page |
string |
(optional) Page number to paginate through results |
state |
enum |
(optional) The state that returned requests needs. Defaults to any state. Can be pending , confirmed , completed or canceled . |
from |
Timestamp | (optional) The minimum datetime that a content request should have been completed. Default is to not filter on from date. |
Headers
Authorization: Bearer your-token-here
Response 200 OK
{
"page": 1,
"pages": 3,
"total": 23,
"requests": [
{
"id": "generated-unique-id",
"state": "completed",
"created": "2016-02-23T09:02:08.22Z",
"completed": "2016-02-26T11:05:43.40Z",
"language": {
"source": "sv",
"target": "en"
},
"fields": [
{
"id": "body",
"type": "localizable",
"data": "html",
"value": "<p>This text can contain <strong>HTML tags</strong></p>",
"originalValue": "<p>Denna text kan innehålla <strong>HTML taggar</strong></p>"
}
]
},
...
]
}
Response 400 Bad Request
If any of the parameters are invalid.
Response 403 Forbidden
If no authorization header is sent or if the header is not on the form
Bearer your-token-here
or if the token is invalid.