Audience List Management

These endpoints create and update list Audiences in Teak: Audiences made from a list of player IDs, like the ones you can upload as a CSV in the Dashboard. Audiences are visible in the Dashboard in the Audiences section, and Schedules send Messages to them (see Bulk Schedule Creation).

An Audience is loaded in the background after you send the list. Its upload_state tells you where it is. Wait for it to be ready before you send a Schedule to the Audience, and before you send the list again.

Creation

Endpoint

Request Type

POST

Content-Type

application/json

Rate Limiting

5 requests per second

Required Parameters

Name Description

game_id

Your Teak App ID

secret_key

Your Teak Server Secret

name

The name of the Audience to create. Limited to 255 characters. Must not match the name of another Audience for the game that isn’t archived.

players

An array of objects, one per player the Audience should contain, like [{"id": "player-1"}, {"id": "player-2"}]. id is the player ID you pass to Teak when you identify the player, as a non-blank string or a whole number. id is the only key an object accepts today; any other key is an error. Repeated IDs count once. IDs that don’t match a player are left out of the Audience.

Optional Parameters

Name Description

description

A description of the Audience, shown in the Dashboard.

archived

A boolean value indicating if the Audience is created archived. Defaults to false. Accepted falsy values are false, 0, "false" and "0". Sending null is the same as leaving the parameter out. All other values will be interpreted as truthy.

Success Response

Status Code

200

Response Body

JSON dictionary with "status" and "audience" keys. "status" will be "ok". "audience" will contain an object representing the Audience with the following keys: id, name, description, archived, upload_state, matched_count, unmatched_count. See The Audience Object for what the keys mean.

Example
{"status":"ok","audience":{"id":12345,"name":"Spring sale testers","description":"Players for the spring sale test","archived":false,"upload_state":"uploaded","matched_count":null,"unmatched_count":null}}

Error Responses

Not Found

Status Code

404

Response Body

JSON dictionary with "status" and "errors" keys. "status" will be "error". "errors" will contain the key "game_id" if the App ID is unknown.

Validation Error

Status Code

422

Response Body

JSON dictionary with "status" and "errors" keys. "status" will be "error". "errors" will be a dictionary in which the keys are the parameter which failed to meet requirements, and the values will be an array of human readable messages for failed validations.

Authorization Error

Status Code

403

Response Body

JSON dictionary with "status" and "errors" keys. "status" will be "error". "errors" will contain the key "authorization".

Rate Limit Response

Status Code

429

Response Body

JSON dictionary with "status" and "errors" keys. "status" will be "rate_limit". "errors" will contain the key "rate_limit".

Updating

Endpoint

Request Type

PATCH or PUT

Content-Type

application/json

Rate Limiting

5 requests per second

Changes the name, description or archived state of a list Audience, or replaces its list of players. Only the parameters you send change.

Sending players replaces the whole list, and Teak loads the Audience again. Wait for upload_state to be ready before you send the list again.

This endpoint only works on list Audiences. An Audience defined by rules in the Dashboard isn’t found.

Required URL Fields

Name Description

id

The id of a list Audience, as specified by the "id" field in the API response.

Required Parameters

Name Description

game_id

Your Teak App ID

secret_key

Your Teak Server Secret

Optional Parameters

Name Description

name

A new name for the Audience. Limited to 255 characters. Must not match the name of another Audience for the game that isn’t archived.

description

A new description for the Audience.

archived

A boolean value indicating if the Audience is archived or not. Defaults to the current Audience archived state. Accepted falsy values are false, 0, "false" and "0". Sending null is the same as leaving the parameter out. All other values will be interpreted as truthy. An archived Audience can’t be found by name by Schedules. Unarchiving an Audience is an error if another Audience that isn’t archived has its name.

players

An array of player objects that replaces the Audience’s list. Follows the same rules as when creating an Audience, and can’t be empty.

Success Response

Status Code

200

Response Body

JSON dictionary with "status" and "audience" keys, as when creating an Audience.

Error Responses

Not Found

Status Code

404

Response Body

JSON dictionary with "status" and "errors" keys. "status" will be "error". "errors" will contain the key "id" if there is no list Audience with that id, or the key "game_id" if the App ID is unknown.

Validation Error

Status Code

422

Response Body

JSON dictionary with "status" and "errors" keys. "status" will be "error". "errors" will be a dictionary in which the keys are the parameter which failed to meet requirements, and the values will be an array of human readable messages for failed validations.

Authorization Error

Status Code

403

Response Body

JSON dictionary with "status" and "errors" keys. "status" will be "error". "errors" will contain the key "authorization".

Rate Limit Response

Status Code

429

Response Body

JSON dictionary with "status" and "errors" keys. "status" will be "rate_limit". "errors" will contain the key "rate_limit".

Reading an Audience

Endpoint

Request Type

GET

Rate Limiting

5 requests per second

Use this endpoint to check on an Audience after you create it or send it a new list. Like updating, it only finds list Audiences.

Required URL Fields

Name Description

id

The id of a list Audience, as specified by the "id" field in the API response.

Required Parameters

Send these as query parameters.

Name Description

game_id

Your Teak App ID

secret_key

Your Teak Server Secret

The Audience Object

Every successful response in this page carries an "audience" object with these keys:

id

The id of the Audience.

name

The name of the Audience.

description

The description of the Audience.

archived

true if the Audience is archived.

upload_state

The Audience’s loading state. One of "uploaded", "looking_up", "requesting_warehouse_import", "requested_warehouse_import" or "ready". The Audience is complete when this is "ready".

matched_count

The number of IDs in the latest list that matched a player. null until Teak has counted them.

unmatched_count

The number of IDs in the latest list that didn’t match a player, so aren’t in the Audience. null until Teak has counted them. Check this before you send.

Success Response

Status Code

200

Response Body

JSON dictionary with "status" and "audience" keys. "status" will be "ok". "audience" is the object described above.

Example
{"status":"ok","audience":{"id":12345,"name":"Spring sale testers","description":"Players for the spring sale test","archived":false,"upload_state":"ready","matched_count":2,"unmatched_count":0}}

Error Responses

Not Found

Status Code

404

Response Body

JSON dictionary with "status" and "errors" keys. "status" will be "error". "errors" will contain the key "id" if there is no list Audience with that id, or the key "game_id" if the App ID is unknown.

Authorization Error

Status Code

403

Response Body

JSON dictionary with "status" and "errors" keys. "status" will be "error". "errors" will contain the key "authorization".

Rate Limit Response

Status Code

429

Response Body

JSON dictionary with "status" and "errors" keys. "status" will be "rate_limit". "errors" will contain the key "rate_limit".