Webhooks

Webhooks are custom HTTP callbacks from WebTranslateIt to any URL you specify. They are called whenever a transaltion is made on WebTranslateIt.

Setup a Webhook

A webhook can be setup in your project settings. Provide the webhook section with the URL of your webservice and WebTranslateIt will request a HTTP POST request everytime a translation was made on your project.

The HTTP POST request made contains a so-called payload which are attributes indicating what was updated.

You can also use a Slack Incoming Webhook to have WebTranslateIt post about translation updates in a channel.

Webhook requests are made in the background so there can be a small delay between the moment a translation is saved and the time the webhook request is made. Timeout is set to drop requests exceeding 10 seconds.

There are two different kinds of payloads, single payloads and multiple payloads.

Single Payload

A single payload is a payload sent for a single translation made from the web interface. Here is an example payload.

{ "payload": [{
      "project_id": 123,
      "string_id": 1234,
      "user_id": 1,
      "locale": "fr",
      "file_id": 12345,
      "api_url": "https://webtranslateit.com/api/projects/:api_token/files/12345/locales/fr",
      "translation": {
        "id": 3388316,
        "locale": "fr",
        "text": "Are you sure you want to delete this comment?",
        "status": "status_unproofread",
        "created_at": "2011-03-23T19:27:54Z",
        "updated_at": "2013-04-12T14:37:25Z",
        "version": 16,
        "string": {
          "id": 772316,
          "key": "_comment.delete_are_you_sure",
          "plural": false,
          "type": "String",
          "dev_comment": null,
          "status": "Current"
        }
      }
    }
  ]
}

Multiple Payload

A multiple payload is a payload for a group of translations that were made from a batch operation or a file upload. Instead of sending thousands of single payloads WebTranslateIt sends a payload containing an array of translation changes. In order not to make too large requests, requests are capped to 50 changes.

{
    "payload": [{
            "project_id": 123,
            "string_id": 1234,
            "user_id": 123,
            "locale": "fr",
            "file_id": 12345,
            "api_url": "https://webtranslateit.com/api/projects/:api_token/files/12345/locales/fr",
            "translation": {
                "id": 3388316,
                "locale": "fr",
                "text": "Are you sure you want to delete this comment?",
                "status": "status_unproofread",
                "created_at": "2011-03-23T19:27:54Z",
                "updated_at": "2013-04-12T14:37:25Z",
                "version": 16,
                "string": {
                    "id": 1234,
                    "key": "_comment.delete_are_you_sure",
                    "plural": false,
                    "type": "String",
                    "dev_comment": null,
                    "status": "Current"
                }
            }
        },

        {
            "project_id": 123,
            "string_id": 1235,
            "user_id": 123,
            "locale": "fr",
            "file_id": 12345,
            "api_url": "https://webtranslateit.com/api/projects/:api_token/files/12345/locales/fr",
            "translation": {
                "id": 3388317,
                "locale": "fr",
                "text": "Another translation",
                "status": "status_unproofread",
                "created_at": "2011-03-23T19:27:54Z",
                "updated_at": "2013-04-12T14:37:25Z",
                "version": 16,
                "string": {
                    "id": 1235,
                    "key": "Another segment",
                    "plural": false,
                    "type": "String",
                    "dev_comment": null,
                    "status": "Current"
                }
            }
        }
    ]
}

What can you do with a webhook?

You could use a webhook to:

  • download the latest version of your linguistic file on your webserver, so translators can live-reload your website.
  • create a new build of your software and make it available to download.
  • automatically commit the new version of the file to your Version Control System.
  • send an e-mail notification or write a line on Campfire, Slack or IRC.

More information about webhook

Next Up: API. This document describes the resources that make up the WebTranslateIt API… »