Only your server makes these calls. An editor session has no screen for an A/B test or a translation, so a customer’s browser cannot make one. Your own page can show what your server reads: a customer’s tests, the numbers of one, the languages of a translation.
What you need
- A partner key. Every call on this page is made from your server with your
wgt_prt_key (see Partner API Key). Keep it there. - A customer, and compositions filed under them. A test compares the customer’s compositions, and a translation starts from one of them. Make the managed user first and file their compositions under them (see Filing Content Under a Managed User).
- The id of your partner workspace. Everything your customers make is filed in your partner workspace. Its id is the
{workspaceId}of the A/B test calls and the{orgId}of the two calls that list and make translations ($WIDGETIC_PARTNER_WORKSPACE_IDbelow), and it is theworkspaceIdthat the answer of an editor session carries. The calls on one translation take no workspace.
Name the customer
SendX-Managed-User-Id (Widgetic’s id for the managed user) or X-Managed-User-External-Id (your own externalId), one of the two, on every call about a customer’s test or translation.
- A list is the customer’s. With the header,
GET /workspaces/{workspaceId}/ab-testsandGET /organizations/{orgId}/translationsanswer that customer’s rows and no others. Without it, they answer everything in your partner workspace, and each row says whose it is inmanagedUserIdandmanagedUserExternalId(bothnullfor one that belongs to no customer in particular). - What you make is the customer’s. A test or a translation made with the header is filed under that customer, at that moment, and for good: there is no field to name another customer, and no way to move it. A
managedUserIdin a body or a query is not read. - What you change must be theirs. A call on one test or translation with the header works only if it is filed under that customer.
A/B tests
Each version of a test shows one composition, and the shares of all versions add up to 100. The goal,primaryMetric, is what the test is judged on: GET /metrics/available lists the goals a test can measure, and the one you pick has to be among the ones it says are available. That call needs no key and takes no customer header.
Make a test
A test starts as a draft, so nothing a visitor sees changes until you start it. Every version has to be a composition filed under the customer.201, and the test is one level down, at data.data. It is shortened here:
id of each version: you need one to name a winner. Some goals are counted by the embed itself and others have to be reported by the widget, which GET /metrics/available says for each. POST /workspaces/{workspaceId}/ab-tests/validate-goal-tracking checks what the compositions you picked can be measured on before you make the test, and GET /workspaces/{workspaceId}/compositions/{id}/ab-goal-targets lists the elements of a composition that can be a version’s goalTarget, when a goal should count on one element and not anywhere in the widget.
With the TypeScript SDK the header is an argument of the call: xManagedUserId, or xManagedUserExternalId for your own id.
Run a test
A test reaches visitors only while it is
running. A test that has ended (completed, or graduated when it had a winner) stays ended. Every write but the delete takes an Idempotency-Key (see Idempotency), and a write that carries the revision you last read is refused with 409 when the test changed since (details.reason is revision_changed), so that two writers do not overwrite each other.
Read the results
GET /workspaces/{workspaceId}/ab-tests/{testId}/statisticsanswers what the test has gathered: visitors and goals reached overall and for each version, how each version compares with the control, and the advice on what to do next. Unlike most calls of a test, it sends its data once, indata.GET /workspaces/{workspaceId}/ab-tests/{testId}/auto-stop-checksays whether the test should stop by now: its duration is over, it reached significance, or it meets its graduation threshold.GET /workspaces/{workspaceId}/ab-tests/{testId}/diagnosisis an AI review of what the versions change, and whether the challenger is safe to promote. It calls another service, so it is slower than the other reads: ask for it when you want it.
Translations
A translation is made while your call runs: the original is copied once for each language, and each copy is translated by a language model. Give the request a generous timeout, and do not send it again when it times out, because the call takes noIdempotency-Key: list the customer’s translations first, and use the one that was made.
Make a translation
GET /translations/supported-languages lists the languages, and GET /translations/language-presets the groups of them (EU, APAC, and so on) that can be chosen in one go. Neither needs a key or a customer header. The original has to be a composition filed under the customer, and each copy is filed under the customer too.
201, with the translation in data.translation and each language in its variants. Read the status of every variant: active is a copy that is ready, translating one that is not finished, and error one that failed. A language that failed is made again by asking for it again (see Change the languages). The translation starts as a draft, and the original language is always one of its variants.
With the TypeScript SDK:
Change the languages
These calls take the id of the translation and no workspace. The translation has to be filed under the customer in the header.
A translation holds up to 20 languages, the original included. Adding languages and translating again are slow for the same reason as making a translation. Adding languages, translating again and changing the status take an
Idempotency-Key; making a translation and the two calls that remove one do not. The calls that change a translation, deleting it aside, also take the revision you last read, when you want a write refused if the translation changed since (409, and details.reason is revision_changed). A translation is shown to visitors only while it is active, so set it with PUT /translations/{id}/status when the languages are ready, and only a language whose copy is ready is shown.
Read the views
GET /translations/{id}/analytics compares the views of the languages. Without a period it covers 30d; the others are 7d, 90d and all_time.
Show it on a page
A test and a translation reach a visitor through the same script as any other embed (see Embedding widgets), with an element that names the test or the translation in place of a composition:TEST_ID and TRANSLATION_ID are the id of the test and of the translation. A test is served only while it is running, and a translation only while it is active.
What belongs to whom
- A customer’s tests and translations are theirs. With the header, another customer’s test or translation, one you made without a header and one that does not exist all answer
404with the same words, so you cannot tell them apart:RESOURCE_AB_TEST_NOT_FOUNDfor a test,RESOURCE_TRANSLATION_NOT_FOUNDfor a translation. A test or a translation that is not filed under a customer is not any customer’s. - A test compares the customer’s compositions only. A version, or the original of a translation, that is another customer’s, one you made without naming a customer or another account’s reads as missing:
404withRESOURCE_COMPOSITION_NOT_FOUND. - The workspace is your partner workspace. The id of another workspace answers
404withRESOURCE_WORKSPACE_NOT_FOUND, and a word where the id belongs (me, say) answers403withMANAGED_USER_SCOPE_ROUTE_NOT_AVAILABLE. - The customer must be yours, and the key a partner’s. An id that is not one of your managed users answers
404withMANAGED_USER_NOT_FOUND, and so does any API key that is not a partner’s. A call that is not made with an API key answers403withMANAGED_USER_SCOPE_NOT_ALLOWED, and an empty, repeated or malformed header is400withMANAGED_USER_SCOPE_INVALID. - A customer you switched off keeps its tests and translations, and you can still read and change them, but you cannot make a test or a translation for it, or add a language to one:
409withMANAGED_USER_INACTIVE. - Your account owns them all. They run under your account and your agreement, as your compositions do. Deleting a managed user does not delete its tests and translations: they stay in your account and keep working on every page that shows them, and only the label that said whose they were is removed (see Deleting Managed Users).
- Other calls stay yours. A call about A/B tests or translations that this page does not list is not about one customer’s test or translation, and with either header it answers
403withMANAGED_USER_SCOPE_ROUTE_NOT_AVAILABLE. The calls an embed makes for a visitor take no key and no header.
Limits and cost
- Up to 50 A/B tests and 25 translations for each customer, in any state. Another one is refused with
422andBUSINESS_OPERATION_INVALID, withreasonin its details (too_many_ab_testsortoo_many_translations) andlimit(the number). The limit is counted for each customer, so one customer cannot use up the room of another, or yours: what you make yourself is not counted. Delete what a customer no longer needs. - A test has two to four versions. A translation holds up to 20 languages, and one call adds at most 10.
- They take no credits. Making and running a test is not an AI call, and a translation, although it sends the text of the composition to a language model, does not use your credits or count against a customer’s allowance either.
Errors
Next Steps
Managed Users
File your customers’ content under them
Workflows
The same two headers on the calls of workflows
Embedding widgets
Put a published composition on a page
Idempotency
Send a write twice and have it done once