Context

Upload new context and run automatic context matching

Changed on

Combines two endpoints:

  • Upload new context
  • Run automatic context matching

The following context types are supported via the Smartling API:

  • HTML: HTML files or files with content type text/html
  • IMAGE: Image files
  • VIDEO:
    • Video file
    • Link to video, such as:
      • YouTube link
      • Vimeo link
      • Direct link to an .mp4 file

Strings to match are retrieved from the project specified by the projectId and can be filtered further by the optional matchParams parameter.

If the uploaded file doesn't match any string, the context may not be created.

Example of the raw request accepted by this API:

Content-Type: multipart/form-data; boundary
----------------------------293641908835402749402839
Content-Disposition: form-data; name="content"; filename="example.html"
Content-Type: text/html
<html>
  <body>
    <div> bla</div>
  </body>
</html>
----------------------------293641908835402749402839
Content-Disposition: form-data; name="name"
https://your.domain.com/path/example.html
----------------------------293641908835402749402839
Content-Disposition: form-data; name="matchParams"
Content-Type: application/json
{
  "contentFileUri":"example.properties",
  "stringHashcodes": [],
  "overrideContextOlderThanDays": 1
}
post/context-api/v2/projects/{projectId}/contexts/upload-and-match-async

Request

  • Base URL
    https://api.smartling.com
  • Auth
    HTTP bearer

Path parameters

projectIdstring required

Unique identifier of a Smartling project — 9 lowercase alphanumeric characters.

Example:84c012a33

A unique project identifier. This can be found in the Smartling Dashboard under Account Settings > API.

Request body multipart/form-data

namestring

Context name. Will overwrites the content's file name if specified. Parameter meanings for different context types:

Context TypeMeaning
HTMLContext URL or file name. If a valid URL is used, all relative links to resources within the context file will be resolved based on this URL. If the file name is used, the context file should have the <base /> tag specified with the valid URL to resolve all relative links to resources. In all other cases, links to resources will not be resolved and the context might not show correctly. Defaults to context file name if not specified.
IMAGEImage file name.
VIDEOLink to a publicly available video in case content field is empty. The parameter is required for this particular case. Otherwise, video file name.
contentstring binary required

The context file to upload.

It should be one of the supported content types(user should insert content type instead of the *. E.g. image/jpeg.):

  • image/*
  • text/html
  • video/*

Maximum file upload size is:

  • 20MB – for HTML and image files.
  • 500MB – for video files.

Note: Exclude this parameter if you choose to upload a video context pointing to external MP4 file, youtube or vimeo.

Example request

{
  "matchParams": {
    "contentFileUri": "/content/en/home.json",
    "stringHashcodes": [
      "d41d8cd98f00b204e9800998ecf8427e"
    ],
    "translationJobUids": [
      "j45v1uvsi3tx"
    ]
  }
}

Response

ACCEPTED

Example response

{
  "response": {
    "data": {
      "processUid": "097ecbc2-8f1b-4ce5-b5c4-d48c3f0e5d9e"
    }
  }
}

Changes

    • breaking

      added the pattern ^[a-z0-9]{9}$ to the path request parameter projectId

    • breaking

      added to the / request property allOf list

    • breaking

      added the pattern ^[a-f0-9]{32}$ to the request property //

    • breaking

      added the pattern ^[a-z0-9]{12}$ to the request property //

    • breaking

      the response property /// became nullable for the status

    • breaking

      the response property /// became nullable for the status

    • breaking

      the response property /// became nullable for the status

    • breaking

      the response property /// became nullable for the status

    • breaking

      the response property /// became nullable for the status

    • breaking

      the response property /// became nullable for the status

    • breaking

      the response property /// became nullable for the status

    • breaking

      the response property /// became nullable for the status

    • breaking

      the // response's property type changed from string to no type, and format from uuid to no format for status

    • info

      for the path request parameter projectId, the format was generalized from uuid to no format

    • info

      the / request property type was generalized from string to no type

    • info

      the // request property format was generalized from hash to no format

    • info

      the // request property format was generalized from hash to no format

    • info

      added to the // response property allOf list for the response status

    • breaking

      the request property type changed from string to object

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the optional property // to the response with the status

    • info

      response property response/data/matchId deprecated