HTTP APIs

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> and use it as the value of the Authorization header.

--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:

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": "{}"
}'

A successful response contains the schedule ID. For example:

{
    "id": "f58a376c-2d4d-50a9-a231-61477fdaf5da"
}

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.

Retrieve schedules

You can inspect the schedule you deployed by sending the following request:

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 could look as follows:

{
  "id": "string",
  "name": "Example Recurring every hour",
  "eventName": "example-event",
  "type": "recurring",
  "schedule": "0 * * * *",
  "payloadVersion": 1,
  "payload": "{}"
}

The response contains the following fields:

  • id: The schedule configuration ID.
  • name: The schedule configuration name.
  • eventName: The name of the event that is emitted when the schedule is triggered.
  • type: The type of the schedule configuration. Can be recurring or one-time.
  • schedule: The schedule configuration in cron format, or a RFC3339 timestamp, depending on the type field.
  • payloadVersion: The version of the payload.
  • payload: The JSON object that is used as the event payload to forward parameters to Cloud Code script or module.

To preview all the schedules you have deployed, send the following request:

curl 'https://services.api.unity.com/scheduler/v1/projects/<PROJECT_ID>/environments/<ENVIRONMENT_ID>/configs' \
--header 'Authorization: Basic <SERVICE_ACCOUNT_CREDENTIALS_ENCODED>'

The response could look as follows:

{
  "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": ""
}

You can also use pagination by setting query parameters. For example, to get the first two configurations, send the following request:

curl 'https://services.api.unity.com/scheduler/v1/projects/<PROJECT_ID>/environments/<ENVIRONMENT_ID>/configs?limit=2' \
--header 'Authorization: Basic <SERVICE_ACCOUNT_CREDENTIALS_ENCODED>'

The response would then be:

{
  "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>"
}

Using the after token, you can get the next page of results. For example:

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>'

The last schedule is returned:

{
    "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:

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>'

An empty response indicates a successful deletion.