Get Started with the Agentforce Operations REST API
Use the Agentforce Operations REST API to access and manage workspace resources, such as blueprints, workflows, and users. This guide shows you how to set up authentication and make an API call.
Prerequisites
Before you begin:
- You have an active Agentforce Operations workspace.
- You have an Admin role in your Agentforce Operations workspace.
Overview
All REST API calls to your Agentforce Operations workspace require two values: an OAuth access token and a workspace UUID. Get the OAuth access token by using a service account’s client ID and client secret. Access tokens expire after 2 hours. Find your workspace UUID in your browser’s developer tools.
This guide walks you through:
- Creating a service account and saving its credentials
- Finding your workspace UUID
- Requesting an OAuth access token
- Making your first API call
Create a Service Account
A service account is a dedicated API-only user in your Agentforce Operations workspace. Unlike a regular user account, a service account authenticates programmatically by using a client ID and client secret rather than a username and password. To create the account, use your admin session credentials. After you create it, you use the service account’s client ID and client secret to request OAuth access tokens for all REST API calls.
-
Get your session bearer token.
-
Log in to your Agentforce Operations workspace in a browser.
-
Open your browser’s developer tools and click the Console tab.
-
To get your session bearer token, enter this command:
1"Bearer " + JSON.parse(localStorage.getItem('_auth0_user'))['token'] -
Copy the returned bearer token, including the
Bearerprefix.
-
-
Create the service account and get its client ID and client secret.
-
Open the GraphiQL playground at your workspace’s
/playgroundpath. Go tohttps://<your-instance>.regrello.salesforce.com/playground, replacing<your-instance>with your tenant prefix. -
In the Headers section, add your bearer token:
1{ 2 "Authorization": "<your-bearer-token>" 3} -
Refresh the browser window.
-
In the query pane, enter and run this mutation. Replace the
namevalue with a name for your service account.1mutation { 2 createServiceAccountUser(input: { 3 accessLevel: INTERNAL, 4 name: "Your Service Account Name", 5 }) { 6 user { 7 id 8 email 9 name 10 } 11 clientId 12 clientSecret 13 } 14}The response includes your service account’s
clientIdandclientSecret. -
Copy and save your client ID and client secret in a secure location such as a password manager. You use this information each time you get an access token. An access token expires after 2 hours.
You can’t view the client ID or client secret after you leave the GraphiQL page. If you lose either credential, you must create another service account to get new credentials.
Important
-
To view and manage your workspace’s service accounts, in the navigation panel, select Admin, click the People tab, and use “service-account” as the filter.
You can edit a service account’s details or deactivate it, but you can’t view its client ID or client secret again.
Note
-
Find Your Workspace UUID
Every API call requires your workspace UUID.
-
Open your Agentforce Operations workspace in a browser.
-
Open your browser’s developer tools. Press F12 (Windows) or Command+Option+I (Mac).
-
Click the Network tab.
-
Refresh the page.
-
In the filter box, type
CurrentTenantQuery.If
CurrentTenantQuerydoesn’t appear, refresh the page again while the Network tab is open.Tip
-
Click a
CurrentTenantQueryrequest, then click the Response tab. -
Copy the value of the
uuidfield. This string is your workspace UUID.
Get an Access Token
All calls to the Agentforce Operations REST API require a token. Create a token by using the client ID, the client secret, and your workspace UUID. An access token expires after 2 hours.
-
Send a POST request to the token endpoint with your service account credentials and workspace UUID. In the code sample, replace
<your-workspace-uuid>,<your-client-id>,<your-client-secret>, and<your-instance>with the values for your workspace.1curl -X POST \ 2 -H 'Content-Type: application/x-www-form-urlencoded' \ 3 --data-urlencode 'grant_type=client_credentials' \ 4 --data-urlencode 'client_id=<your-client-id>' \ 5 --data-urlencode 'client_secret=<your-client-secret>' \ 6 https://<your-instance>.regrello.salesforce.com/oauth/<your-workspace-uuid>/token -
Verify your response. A successful response looks like this:
1{ 2 "access_token": "eyJ...(shortened)", 3 "expires_in": 7200, 4 "token_type": "Bearer" 5} -
Copy the
access_tokenvalue to use in your API calls.Tokens expire after 2 hours.
Note
Call the API
With your access token and workspace UUID, you’re ready to call the API.
-
Call an API endpoint. Every request requires two headers:
AuthorizationandX-Regrello-Workspace-ID. This example retrieves a list of published blueprints in your workspace. In the code sample, replace<your-instance>,<your-access-token>, and<your-workspace-uuid>with the values for your workspace.1curl 'https://<your-instance>.regrello.salesforce.com/api/v1/blueprints' \ 2 -H "Authorization: Bearer <your-access-token>" \ 3 -H "X-Regrello-Workspace-ID: <your-workspace-uuid>" -
Verify the response. A successful response returns HTTP 200. In the get blueprints list example, the response body looks like this:
1[ 2 { 3 "blueprintUuid": "ckuJA2XGT-Q", 4 "description": null, 5 "id": 2227, 6 "name": "API Example", 7 "numberOfStages": 1, 8 "type": "COMPANY", 9 "versionNumber": 1 10 } 11]Pagination details are in the
SFDC-Pagination-Offset,SFDC-Pagination-Limit,SFDC-Pagination-Total-Count, andSFDC-Pagination-Result-Countresponse headers.Note