Related pages

HTTP API

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.

Note

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.

Warning

Our API can handle most queries very quickly, but some queries can be though on our API, if you find yourself using lots of criterias and joining them using or and and-criteria consider contacting your developer contact at Contentor to discuss the impact of your HTTP request.

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 request
  • completed - Timestamp range for querying the completion date of the content request
  • state - String representing a valid state value, see Content requests for values
  • source - The source of the content request, should be api 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 request
  • language.target - String representing the target locale of the content request
  • id - Query on the identifier of a content request

Example: Query for content requests created last week

{
  "criteria": [
    {
      "type": "source",
      "criteria": "api"
    },
    {
      "type": "created",
      "criteria": "last-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.

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.