Content API
The Content API serves as the core interface for managing content-related tasks. It facilitates two key functions: sending content for localization (including also import and versioning) and generating new content. Whether you're adapting existing materials for different markets or creating fresh content, the Content API streamlines these processes, ensuring efficiency and quality.
This page provides a concise introduction, offering minimal examples for creating and querying a request. For comprehensive details on constructing requests, utilizing various fields, and exploring preferences, please refer to our dedicated content requests page.
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": "en-GB",
"target": "sv-SE"
},
"fields": [
{
"id": "body",
"type": "localizable",
"data": "html",
"value": "<p>This text could contain various <strong>HTML tags</strong></p>"
}
]
}
Response 200 OK
{
"id": "generated-unique-id",
"state": "pending",
"created": "2023-11-01T09:02:08.22Z",
"fields": [
...
]
}
Response 400 Bad Request
If an invalid content request is sent, either with no data or if data is missing.
{
"errors": [
"..."
]
}
Response 403 Forbidden
If no authorization header is included, or if the header doesn't follow the format Bearer your-token-here,
or if the provided token is invalid, the API will respond with a 403 Forbidden
HTTP status code.
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 |
number |
(optional) Page number to paginate through results |
pageSize |
number |
(optional) Number of requests per page |
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 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": "2023-10-23T09:02:08.22Z",
"completed": "2023-10-24T11:05:43.40Z",
"language": {
"source": "en-GB",
"target": "sv-SE"
},
"fields": [
{
"id": "body",
"type": "localizable",
"data": "html",
"value": "<p>Denna text kan innehÄlla diverse <strong>HTML taggar</strong></p>",
"originalValue": "<p>This text could contain various <strong>HTML tags</strong></p>"
}
]
},
...
]
}
Response 400 Bad Request
If an invalid content request is sent, either with no data or if data is missing.
{
"errors": [
"..."
]
}
Response 403 Forbidden
If no authorization header is included, or if the header doesn't follow the format Bearer your-token-here,
or if the provided token is invalid, the API will respond with a 403 Forbidden
HTTP status code.
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": "2023-10-25T07:43:13.487Z"
},
...
}
Response 403 Forbidden
If no authorization header is included, or if the header doesn't follow the format Bearer your-token-here,
or if the provided token is invalid, the API will respond with a 403 Forbidden
HTTP status code.
Response 404 Not found
If the :id
request does not exist.