HTTP APIs
Create and manage schedule configurations that emit events at set or recurring moments using the REST API.
Read time 2 minutesLast updated 18 hours ago
You can use the raw HTTP APIs to manage schedule configurations. Deploying a schedule configuration creates a schedule that emits events at a set or recurring moment in time.
Using the API
The Scheduler Admin API documentation contains a detailed description of admin operations, such as creating, reading, and deleting schedules. The documents include information on authentication, endpoints, and request and response formats, along with examples. You can download them in OpenAPI format and use them to set up your own automation. To use the API, authenticate using a Service Account.Authorization header
To authenticate the requests, use Basic Authentication). Create a service account and base64 encode the<KEY_ID>:<SECRET_KEY>Authorization--header 'Authorization: Basic <SERVICE_ACCOUNT_CREDENTIALS_ENCODED>' \
Deploy schedules
You can deploy a recurring schedule configuration to the remote environment by sending the following request:A successful response contains the schedule ID. For example:curl 'https://services.api.unity.com/scheduler/v1/projects/<PROJECT_ID>/environments/<ENVIRONMENT_ID>/configs' \--header 'Content-Type: application/json' \--header 'Authorization: Basic <SERVICE_ACCOUNT_CREDENTIALS_ENCODED>' \--data '{ "name": "Example Recurring every hour", "eventName": "example-event", "type": "recurring", "schedule": "0 * * * *", "payloadVersion": 1, "payload": "{}"}'
You can use this ID to retrieve the schedule configuration or to delete it. Once you have deployed the schedule configuration, it's automatically triggered at the specified time, and sends an event to the Triggers service.{ "id": "f58a376c-2d4d-50a9-a231-61477fdaf5da"}
Retrieve schedules
You can inspect the schedule you deployed by sending the following request:The response could look as follows:curl 'https://services.api.unity.com/scheduler/v1/projects/<PROJECT_ID>/environments/<ENVIRONMENT_ID>/configs/<CONFIG_ID>' \--header 'Authorization: Basic <SERVICE_ACCOUNT_CREDENTIALS_ENCODED>'
The response contains the following fields:{ "id": "string", "name": "Example Recurring every hour", "eventName": "example-event", "type": "recurring", "schedule": "0 * * * *", "payloadVersion": 1, "payload": "{}"}
- : The schedule configuration ID.
id - : The schedule configuration name.
name - : The name of the event that is emitted when the schedule is triggered.
eventName - : The type of the schedule configuration. Can be
typeorrecurring.one-time - : The schedule configuration in cron format, or a RFC3339 timestamp, depending on the
schedulefield.type - : The version of the payload.
payloadVersion - : The
payloadobject that is used as the event payload to forward parameters to Cloud Code script or module.JSON
The response could look as follows:curl 'https://services.api.unity.com/scheduler/v1/projects/<PROJECT_ID>/environments/<ENVIRONMENT_ID>/configs' \--header 'Authorization: Basic <SERVICE_ACCOUNT_CREDENTIALS_ENCODED>'
You can also use pagination by setting query parameters. For example, to get the first two configurations, send the following request:{ "configs": [ { "id": "a0fa56fd-9763-5590-9452-769be3e6c5bb", "name": "Example One Time 2", "eventName": "example-event", "type": "one-time", "schedule": "2024-01-14T07:20:50Z", "payloadVersion": 1, "payload": "{}" }, { "id": "f58a376c-2d4d-50a9-a231-61477fdaf5da", "name": "Example Recurring every hour", "eventName": "example-event", "type": "recurring", "schedule": "0 * * * *", "payloadVersion": 1, "payload": "{}" }, { "id": "fb3e6636-1a99-5a82-97b4-74b5f6678bb2", "name": "Example One Time", "eventName": "example-event", "type": "one-time", "schedule": "2024-01-12T07:20:50Z", "payloadVersion": 1, "payload": "{}" } ], "after": ""}
The response would then be:curl 'https://services.api.unity.com/scheduler/v1/projects/<PROJECT_ID>/environments/<ENVIRONMENT_ID>/configs?limit=2' \--header 'Authorization: Basic <SERVICE_ACCOUNT_CREDENTIALS_ENCODED>'
Using the{ "configs": [ { "id": "f58a376c-2d4d-50a9-a231-61477fdaf5da", "name": "Example Recurring every hour", "eventName": "example-event", "type": "recurring", "schedule": "0 * * * *", "payloadVersion": 1, "payload": "{}" }, { "id": "a0fa56fd-9763-5590-9452-769be3e6c5bb", "name": "Example One Time 2", "eventName": "example-event", "type": "one-time", "schedule": "2024-01-14T07:20:50Z", "payloadVersion": 1, "payload": "{}" } ], "after": "<TOKEN>"}
afterThe last schedule is returned:curl 'https://services.api.unity.com/scheduler/v1/projects/<PROJECT_ID>/environments/<ENVIRONMENT_ID>/configs?limit=2&after=<TOKEN>' \--header 'Authorization: Basic <SERVICE_ACCOUNT_CREDENTIALS_ENCODED>'
{ "configs": [ { "id": "fb3e6636-1a99-5a82-97b4-74b5f6678bb2", "name": "Example One Time", "eventName": "example-event", "type": "one-time", "schedule": "2024-01-12T07:20:50Z", "payloadVersion": 1, "payload": "{}" } ], "after": ""}
Delete schedules
You can delete the schedule configuration by sending the following request:An empty response indicates a successful deletion.curl --request DELETE 'https://services.api.unity.com/scheduler/v1/projects/<PROJECT_ID>/environments/<ENVIRONMENT_ID>/configs/<CONFIG_ID>' \--header 'Authorization: Basic <SERVICE_ACCOUNT_CREDENTIALS_ENCODED>'