A macro is a saved set of actions that can be applied to an entity in Sprinklr. Use Macro API to programmatically apply an existing macro to one or more entities and automate actions that would otherwise be triggered in Sprinklr.
Macro API V3 provides the following operation:
| Operation | Method | Path |
|---|---|---|
| Apply macros | POST | /api/v3/macro/apply |
The request identifies:
- the type of entity through assetClass
- the entities through entityKeys
- the macros to apply through macroIds
The actions performed by a macro are configured in Sprinklr. The API applies an existing macro but does not create, modify, or provide values for the actions within the macro.
Before using Macro API V3:
- Create and configure the macro in Sprinklr.
- Ensure the macro applies to the same entity type specified in assetClass.
- Obtain the ID of each macro you want to apply.
- Ensure that the authenticated user has access to the macro and the entities to which it will be applied.
To create a macro in Sprinklr:
- Click the New Tab icon. Under Platform modules, click Macros within settings.
- In the top-right corner of the Macros window, click Create Macro.
- Enter a Macro Name and Description, and select the entity to apply the macro to from the Apply macro on dropdown.
- Set actions under Automated Actions and Manual Actions.
- Select visibility preferences — all workspaces, specific workspaces, or specific users.
- Click Save.
The actions performed by an API request depend on the configuration of the referenced macro. If the macro configuration changes, subsequent API requests that use the same macro ID use the updated configuration.
For API-driven workflows, ensure that the macro does not depend on user input that can only be provided through an interactive workflow.
Macros are workspace-scoped. Macros can be viewed, edited, and created by admins from Settings, and are available at the Workspace level only. A macro ID that resolves in one workspace may not resolve in another, and visibility rules restrict which users can apply it. If your API user cannot see the macro, the call fails.
Macro IDs are obtained from the Sprinklr UI and can be stored in your configuration. Plan for that as a setup step, and treat a configured macro ID as a dependency that fails at runtime with a 404 if the macro is later deleted.
https://api3.sprinklr.com/{env}/api/v3/macro/applyReplace {env} with your assigned Sprinklr environment.
See APIs | Sprinklr Developer Portal for the published environment list. For the production environment at app.sprinklr.com, omit the {env} segment from the URL.
Environment-scoped everything. API keys and access tokens are scoped to a single environment — a key generated for one returns
401against another even when the request is otherwise perfect. The same is true of your data:macroIdsandentityKeysare environment-specific identifiers. A macro ID copied from a staging workspace will not resolve in production. This is the most common cause of a404on an otherwise correct call.
Macro API V3 uses OAuth 2.0 bearer authentication and an API key.
All calls are authenticated with OAuth 2.0. See API Overview for portal registration, API key and secret generation, and the Authorize flow.
Include the following headers:
| Header | Value | Purpose |
|---|---|---|
Authorization | Bearer {{accessToken}} | Credential used by the API to authenticate a user with the server |
Key | {{apiKey}} | API key that authenticates the application with the server. See API Key and Secret Generation |
Content-Type | application/json | Determines the type of data present in the request body |
Accept | application/json | Determines the acceptable response type from the server |
Both Authorization and Key are required on every call. Sending only one returns 401.
Accept: application/jsonstill matters even though a successful call returns no body. Error responses do return JSON. Keep sending it.
The macro runs as the API user. Macro visibility is governed by workspace and user-level sharing, and the actions a user can take on macros are determined by Macro Permissions. The identity behind your access token must be able to see the macro and be permitted to perform every action inside it. A macro that works for an admin in the UI can fail for a service account.
| Credential | Lifetime |
|---|---|
| Authorization code | 10 minutes |
| API key | No expiry |
| Access token | 30 days by default |
One token pair per API key. Generating a new access token for an API key invalidates the previously issued token and refresh token for that key. Two services sharing one key will knock each other offline. Give each service its own key.
Credential hygiene. Never commit an access token or API key, never paste one into a ticket, and never log the
AuthorizationorKeyheader values. Every credential on this page is a placeholder.
POST https://api3.sprinklr.com/{env}/api/v3/macro/applyApplies one or more saved macros to one or more entities of a single asset class.
| Field | Type | Required | Description |
|---|---|---|---|
assetClass | String | Yes | The asset type on which the macro needs to be applied. For example, UNIVERSAL_CASE for the case asset type |
entityKeys | Array of strings | Yes | Unique identifiers for the entities on which the macro needs to be applied |
macroIds | Array of strings | Yes | Unique identifiers for the macros to be applied |
You can include multiple entity IDs in entityKeys and multiple macro IDs in macroIds. All entities in a request must correspond to the specified assetClass.
Use the assetClass that corresponds to the entity type configured for the macro.
| Value | Entity |
|---|---|
UNIVERSAL_CASE | Case |
MESSAGE | Inbound message |
OUTBOUND_MESSAGE | Outbound message |
USER_GENERATED_CONTENT | UGC asset |
SPR_TASK | Task |
PROFILE | Profile |
CAMPAIGN | Campaign |
SUB_CAMPAIGN | Sub-campaign |
MEDIA_ASSET | Media / SAM asset |
ACCOUNT | Social account |
These values are case-sensitive. Define them as a constant set in your own code.
assetClass identifies a single entity type, include entities of only one asset class in each request. One assetClass per call. The field is singular, so a batch spanning entity types is not possible — split it into one call per asset class.
entityKeys and macroIds are not the same kind of value:
entityKeys— the format depends on the asset class. For a case this is a case number, a short numeric string such as"1724559".macroIds— a 24-character hexadecimal identifier such as"667bf9b8b9d50132d01cfd5d".
Match the identifier form to the asset class you are targeting.
curl -X POST \
'https://api3.sprinklr.com/{env}/api/v3/macro/apply' \
-H 'Authorization: Bearer {{accessToken}}' \
-H 'Key: {{apiKey}}' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{
"assetClass": "UNIVERSAL_CASE",
"entityKeys": [
"1724559"
],
"macroIds": [
"667bf9b8b9d50132d01cfd5d"
]
}'To apply the same macro to multiple entities of the same asset class, include their identifiers in entityKeys:
{
"assetClass": "UNIVERSAL_CASE",
"entityKeys": [
"1724559",
"1724560"
],
"macroIds": [
"667bf9b8b9d50132d01cfd5d"
]
}To apply multiple macros to the specified entities, include their IDs in macroIds:
{
"assetClass": "UNIVERSAL_CASE",
"entityKeys": [
"1724559"
],
"macroIds": [
"667bf9b8b9d50132d01cfd5d",
"667bf9b8b9d50132d01cfd5e"
]
}A successful request returns:
204 No ContentThe API does not return a response body for a successful request.
Ensure that your client handles 204 No Content without attempting to deserialize a response body. For example, your client can evaluate the HTTP status before attempting to process an error response:
response = requests.post(url, headers=headers, json=body)
if response.status_code == 204:
# Request succeeded. There is no response body.
pass
else:
# Handle the error response
error = response.json() Accept both 200 and 204 as success. A client that unconditionally deserializes the response body will throw on an empty one.
A successful call confirms only that the request was accepted. The response carries no result object, no per-entity status, and no job ID to poll — so it does not tell you which entities were affected or which macros ran. To verify an effect, re-fetch the affected entities. Build that into anything consequential.
Because both entityKeys and macroIds are arrays, design your calls so that a failure is attributable: use one assetClass, small entityKeys batches, and one macroId per call when ordering or outcome tracking matters. This costs more requests but makes failures traceable.
Error responses return a JSON body. Each entry in errors has this shape:
| Field | Type | Description |
|---|---|---|
id | String | Error identifier |
code | Integer | Numeric error code |
message | String | Error key, for example account.not.found |
Branch on code or message, not on human-readable text.
| HTTP code | Scenario |
|---|---|
204 No Content | Macro applied. No response body |
400 Bad Request | Missing a required field, unrecognised assetClass, malformed JSON, or an assetClass/entityKeys format mismatch |
401 Unauthorized | Invalid or missing Authorization token or Key header, or credentials from a different environment |
403 Forbidden | The API user lacks Macro Permissions, cannot see the macro under its visibility rules, or is not permitted to perform an action inside it |
404 Not Found | Unknown macroId or entityKey — commonly an identifier copied from a different environment or workspace |
For unsuccessful requests, use the returned error information to identify the cause rather than relying only on the HTTP status.
| Symptom | Likely cause | Fix |
|---|---|---|
| Client throws parsing the success response | Success is 204 with an empty body | Accept 200 and 204; never require a body |
404 on every call | Wrong path | The path is /api/v3/macro/apply |
404 on a call that works elsewhere | macroId or entityKey from a different environment or workspace | Identifiers are environment- and workspace-scoped |
400 on assetClass | Value not one of the ten supported, or wrong case | Use one of the listed values exactly |
400 mentioning entity keys | entityKeys format varies by assetClass | Match the identifier form to the asset class |
403 though the macro works in the UI | The macro is visible to your admin but not to the API user, or the user lacks permission for an action inside it | Check Macro Permissions and workspace/user visibility |
204 returned but nothing changed | The macro contains Manual Actions requiring inputs this endpoint cannot supply | Review the macro's configuration with your admin |
| Cannot tell which entities were affected | The success response is empty by design | Re-fetch the entities to verify |
| Some entities updated, others not | Send smaller batches | Batch size determines how attributable a failure is |
401 with all headers present | Credentials belong to a different environment | Regenerate for the target environment |
401 after previously working | Token expired (30-day default), or a second token was issued for the same key | Refresh; one key per service |
| Behaviour changed without a deploy | An admin edited the macro in the UI | Macro definitions live outside your code |
Update the API version in the endpoint when migrating an existing Macro API integration from V2 to V3:
- POST https://api3.sprinklr.com/{env}/api/v2/macro/apply
+ POST https://api3.sprinklr.com/{env}/api/v3/macro/apply| Element | V2 | V3 | Changed? |
|---|---|---|---|
| Path after version | /macro/apply | /macro/apply | No |
assetClass | Required, String, 10 supported values | Identical | No |
entityKeys | Required, array of strings | Identical | No |
macroIds | Required, array of strings | Identical | No |
| Headers | Authorization, Key, Content-Type, Accept | Identical | No |
| Success response | 204 No Content | 204 No Content | No |
Review existing integrations against the V3 API contract when migrating rather than assuming that all V2 and V3 behavior is identical.
When your ticketing system resolves a case, apply a "Close and tag as resolved" macro rather than issuing separate status, tag, and assignment updates:
{
"assetClass": "UNIVERSAL_CASE",
"entityKeys": ["1724559"],
"macroIds": ["667bf9b8b9d50132d01cfd5d"]
}The advantage over calling individual update endpoints is that the action set stays under admin control — if the close-out process changes, the admin edits the macro and your integration needs no deploy.
One call can carry many entity keys:
{
"assetClass": "MEDIA_ASSET",
"entityKeys": ["<id1>", "<id2>", "<id3>"],
"macroIds": ["<taggingMacroId>"]
}Keep batches small enough that you can attribute a failure, and re-fetch to verify.
macroIds is a list, so several macros can run against the same entities in one call:
{
"assetClass": "UNIVERSAL_CASE",
"entityKeys": ["1724559"],
"macroIds": ["<macroA>", "<macroB>"]
}If two macros write the same field, issue one call per macro so that the order of application is under your control.
Configure a macro that sets Status → Escalated with Escalation Reason → "More information needed", then fire it from your monitoring system when an SLA threshold is crossed. One API call replaces a multi-field update and keeps the escalation policy in the admin's hands.
Treat macro IDs as configuration, not constants. Store them per environment, name them meaningfully in your config, and document which macro each ID refers to. A deleted macro fails at runtime with a 404 and no other warning.
Verify, don't assume. The empty success response means the only way to confirm an effect is to re-read the entity.
Pin down the macro's contents with your admin. Ask specifically whether it contains Manual Actions or has "Ask user for confirmation" enabled — both are designed for an interactive flow rather than a headless call.
Match entityKeys format to assetClass. Case numbers are short numeric strings; other asset classes use 24-character hexadecimal identifiers.
One assetClass per call. The field is singular, so split batches that span entity types.
Do not retry blindly. There is no idempotency key and no result body, so a retry after a timeout may apply the macro twice. If the macro's actions are not naturally idempotent — appending a tag, incrementing a counter, sending a message — a duplicate application has real effects. Prefer re-fetching the entity to determine whether the first call landed.
Keep batches small. Small batches make partial failures attributable and keep you clear of rate limiting.