Trigger Connection Runs

Use the Workspace API to start a run for a saved Connection. The API uses the OAuth 2.0 client credentials flow.

Create an API client

Anyone who can edit the workspace (a workspace editor, or an organization owner or admin) can create credentials on the Integrations page in the workspace sidebar, under Workspace API Clients. Each client is limited to the workspace where it was created. The same card shows the Workspace ID you'll use as workspaceId.

Copy the client ID and client secret when the client is created. The client secret is shown only once.

Get an access token

Exchange the client credentials for an access token:

curl --request POST \
  'https://studio.precog.cloud/api/public/v1/oauth/token' \
  --user '<client-id>:<client-secret>' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data 'grant_type=client_credentials'

A successful request returns:

{
  "access_token": "<access-token>",
  "token_type": "Bearer",
  "expires_in": 3600,
  "scope": "connections:runs:create"
}

The access token expires after one hour and can trigger runs only in the API client's workspace.

Trigger a Connection run

You need these UUIDs:

  • workspaceId: the workspace where the API client and Connection exist
  • connectionId: the saved Connection ID, not its Precog pipeline ID

Find your IDs

  • workspaceId: Open Workspace Settings. In the General Information card, copy the Workspace ID with its copy button. Anyone who can edit the workspace can also copy it from the Workspace API Clients card on the Integrations page.
  • connectionId: Open Connections and select the Connection. In the details header, copy the Connection ID with its copy button.

All workspace members, including viewers, can see both IDs in Workspace Settings and the Connection details header.

Note: Use the Connection ID shown in Precog Studio. The Precog pipeline ID is a different value and won't work with this API.

Send the request

Send an empty POST request with the access token:

ACCESS_TOKEN='<access-token>'
WORKSPACE_ID='<workspace-id>'
CONNECTION_ID='<connection-id>'

curl --request POST \
  "https://studio.precog.cloud/api/public/v1/workspaces/${WORKSPACE_ID}/connections/${CONNECTION_ID}/runs" \
  --header "Authorization: Bearer ${ACCESS_TOKEN}"

Do not send a request body.

Accepted response

A successfully accepted request returns 202 Accepted:

{
  "connectionId": "<connection-id>",
  "status": "accepted"
}

This response means Precog accepted the Connection for execution. It does not mean that the run has completed successfully.

Errors

Token endpoint errors:

StatusErrorMeaning
400unsupported_grant_typeThe request did not use grant_type=client_credentials.
401invalid_clientThe client ID or client secret is missing, malformed, invalid, or revoked.
500server_errorPrecog could not issue the token.

Connection-run endpoint errors:

StatusErrorMeaning
400request_body_not_allowedThe request included a body.
401invalid_tokenThe bearer token is missing, malformed, invalid, expired, or revoked.
402payment_requiredA billing problem prevented the run from starting.
404not_foundThe workspace or Connection was not found within the token's workspace.
409conflictThe Connection is already active, has no runnable datasets, or cannot currently run.
500internal_server_errorPrecog could not start the run.