---
title: "Create string to context bindings"
method: POST
path: "/context-api/v2/projects/{projectId}/bindings"
tags: ["Context"]
---

# Create string to context bindings

`POST /context-api/v2/projects/{projectId}/bindings`

Link context files with the strings they contain.

The binding tells Smartling to show Translators which context images for which strings.

A basic bindings request should contain an object with a `bindings` JSON array, with at least one element (binding) featuring `contextUid` and `stringHashcode` properties:
```JSON
{
  "bindings": [
    {
       "contextUid": "25137b65-e075-4341-8362-14b1a3e558f5",
       "stringHashcode": "bd603147d945h3ec74d6874422ebe4e0"
    }
  ]
}
```

For `IMAGE` context, each binding may have additional `coordinates` data that specifies a rectangular area where the string is located in the image. If not specified, binding will still be created with coordinates `[0,0,0,0]`:
```JSON
{
  "bindings": [
    {
       "contextUid": "25137b65-e075-4341-8362-14b1a3e558f5",
       "stringHashcode": "bd603147d945h3ec74d6874422ebe4e0",
       "coordinates": {
          "top": 50,
          "left": 50,
          "width": 400,
          "height": 400
       }
    }
  ]
}
```

For `HTML` context, each binding may have the `selector` element with `anchors` array, specifying the enclosing the string HTML elements with the corresponding value of the `data-sl-anchor` attribute.
Each `anchor` value can have up to 20 characters and consist of the following characters: `0-9` (more preferably), `A-Z`, `a-z`, `.-_`.
If not specified, binding will still be created with the empty `anchors` array, effectively making it not anchored to a particular element and thus invisible in CAT Tool:
```JSON
{
  "bindings": [
    {
       "contextUid": "25137b65-e075-4341-8362-14b1a3e558f5",
       "stringHashcode": "bd603147d945h3ec74d6874422ebe4e0",
       "selector": {
          "anchors": ["11", "22", "aa-33"]
       }
    }
  ]
}
```

For `VIDEO` context, each binding has the `timecode` data, specifying the start and end time of the string appearance in the video:
```JSON
{
  "bindings": [
    {
        "contextUid": "25137b65-e075-4341-8362-14b1a3e558f5",
        "stringHashcode": "bd603147d945h3ec74d6874422ebe4e0",
        "timecode": {
           "startTime": 1203,
           "endTime": 1450
        }
    }
  ]
}
```

## Path parameters

- `projectId` string, uuid, required

## Request body

- BindingsRequest
  - `bindings` object[] — List of strings-to-context bindings. List size is limited to 150 items.
    - `contextUid` string, uuid, required — Unique identifier for the context.
    - `stringHashcode` string, hash, required — Unique identifier for the translatable.
    - `coordinates` Coordinates — Describes the location and size of a box enclosing the string in a context image. ‘top’ and ‘left’ are the distances in pixels of the top left corner of the string (from the top left of the image). ‘width’ and ‘height’ are the dimensions of the string in pixels. This information is used to highlight the position of the string when displaying the context image in the translation interface (CAT tool). If coordinates are not provided, Smartling will attempt to locate the string on the image using Optical Character Recognition. If OCR fails, coordinates will default to 0, 0, 0, 0. This meaans that the image will be displayed when the string is translated, without any highlighting to show the position of the string.
      - `height` number, required
      - `left` number, required
      - `top` number, required
      - `width` number, required
    - `selector` object — Values for "data-sl-anchor" attributes of HTML elements.
      - `anchors` string[]
    - `timecode` Timecode — Number of seconds for the period of time that a string appears in a video, relative to the video start time.
      - `endTime` integer
      - `startTime` integer

## Response `200`

OK

- CreateBindingsResponse
  - `response` object, required
    - `code` 'SUCCESS', required — Indicates whether the response was successful or what error has occured.
    - `data` object
      - `created` object, required
        - `items` Binding[], required
          - `anchors` string[] — Wrapper HTML element anchor numbers
          - `contextPosition` integer — Binding position in context
          - `bindingUid` string — Unique identifier for the context binding.
          - `contextUid` string, required — Unique identifier for the context.
          - `coordinates` Coordinates — Describes the location and size of a box enclosing the string in a context image. ‘top’ and ‘left’ are the distances in pixels of the top left corner of the string (from the top left of the image). ‘width’ and ‘height’ are the dimensions of the string in pixels. This information is used to highlight the position of the string when displaying the context image in the translation interface (CAT tool). If coordinates are not provided, Smartling will attempt to locate the string on the image using Optical Character Recognition. If OCR fails, coordinates will default to 0, 0, 0, 0. This meaans that the image will be displayed when the string is translated, without any highlighting to show the position of the string.
            - `height` number, required
            - `left` number, required
            - `top` number, required
            - `width` number, required
          - `stringHashcode` string, required — Unique identifier for the translatable.
          - `timecode` Timecode — Number of seconds for the period of time that a string appears in a video, relative to the video start time.
            - `endTime` integer
            - `startTime` integer
        - `totalCount` integer
      - `errors` object
        - `items` object[], required
          - `message` string, required
        - `totalCount` integer

## Other responses

- `400` — Validation error
- `401` — Provided credentials are not valid.
- `429` — Too many simultaneous API requests.
- `500` — Unexpected error

---

[API](https://skmtc.net/smartling/apis/smartling-rest-api-reference.md) · [All operations](https://skmtc.net/smartling/apis/smartling-rest-api-reference/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/smartling/smartling-rest-api-reference/versions/2a73d11e9b98/schema)
