Skip to content

Macro API V3

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:

OperationMethodPath
Apply macrosPOST/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 you begin

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.

Create a macro

To create a macro in Sprinklr:

  1. Click the New Tab icon. Under Platform modules, click Macros within settings.
  2. In the top-right corner of the Macros window, click Create Macro.
  3. Enter a Macro Name and Description, and select the entity to apply the macro to from the Apply macro on dropdown.
  4. Set actions under Automated Actions and Manual Actions.
  5. Select visibility preferences — all workspaces, specific workspaces, or specific users.
  6. 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.

Obtaining macro IDs

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.


Base URL

https://api3.sprinklr.com/{env}/api/v3/macro/apply

Replace {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 401 against another even when the request is otherwise perfect. The same is true of your data: macroIds and entityKeys are environment-specific identifiers. A macro ID copied from a staging workspace will not resolve in production. This is the most common cause of a 404 on an otherwise correct call.


Authentication

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:

HeaderValuePurpose
AuthorizationBearer {{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-Typeapplication/jsonDetermines the type of data present in the request body
Acceptapplication/jsonDetermines the acceptable response type from the server

Both Authorization and Key are required on every call. Sending only one returns 401.

Accept: application/json still 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 lifetimes

CredentialLifetime
Authorization code10 minutes
API keyNo expiry
Access token30 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 Authorization or Key header values. Every credential on this page is a placeholder.


Apply macros

POST https://api3.sprinklr.com/{env}/api/v3/macro/apply

Applies one or more saved macros to one or more entities of a single asset class.


Request body

FieldTypeRequiredDescription
assetClassStringYesThe asset type on which the macro needs to be applied. For example, UNIVERSAL_CASE for the case asset type
entityKeysArray of stringsYesUnique identifiers for the entities on which the macro needs to be applied
macroIdsArray of stringsYesUnique 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.

Supported Asset Classes

Use the assetClass that corresponds to the entity type configured for the macro.

ValueEntity
UNIVERSAL_CASECase
MESSAGEInbound message
OUTBOUND_MESSAGEOutbound message
USER_GENERATED_CONTENTUGC asset
SPR_TASKTask
PROFILEProfile
CAMPAIGNCampaign
SUB_CAMPAIGNSub-campaign
MEDIA_ASSETMedia / SAM asset
ACCOUNTSocial 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.

Identifier formats

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.

Example request

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"
    ]
  }'

Apply a macro to multiple entities

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

Apply multiple macros

To apply multiple macros to the specified entities, include their IDs in macroIds:

{
  "assetClass": "UNIVERSAL_CASE",
  "entityKeys": [
    "1724559"
  ],
  "macroIds": [
    "667bf9b8b9d50132d01cfd5d",
    "667bf9b8b9d50132d01cfd5e"
  ]
}

Response

A successful request returns:

204 No Content

The 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.

The error object

Error responses return a JSON body. Each entry in errors has this shape:

FieldTypeDescription
idStringError identifier
codeIntegerNumeric error code
messageStringError key, for example account.not.found

Branch on code or message, not on human-readable text.


Status codes

HTTP codeScenario
204 No ContentMacro applied. No response body
400 Bad RequestMissing a required field, unrecognised assetClass, malformed JSON, or an assetClass/entityKeys format mismatch
401 UnauthorizedInvalid or missing Authorization token or Key header, or credentials from a different environment
403 ForbiddenThe 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 FoundUnknown 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.

Troubleshooting

SymptomLikely causeFix
Client throws parsing the success responseSuccess is 204 with an empty bodyAccept 200 and 204; never require a body
404 on every callWrong pathThe path is /api/v3/macro/apply
404 on a call that works elsewheremacroId or entityKey from a different environment or workspaceIdentifiers are environment- and workspace-scoped
400 on assetClassValue not one of the ten supported, or wrong caseUse one of the listed values exactly
400 mentioning entity keysentityKeys format varies by assetClassMatch the identifier form to the asset class
403 though the macro works in the UIThe macro is visible to your admin but not to the API user, or the user lacks permission for an action inside itCheck Macro Permissions and workspace/user visibility
204 returned but nothing changedThe macro contains Manual Actions requiring inputs this endpoint cannot supplyReview the macro's configuration with your admin
Cannot tell which entities were affectedThe success response is empty by designRe-fetch the entities to verify
Some entities updated, others notSend smaller batchesBatch size determines how attributable a failure is
401 with all headers presentCredentials belong to a different environmentRegenerate for the target environment
401 after previously workingToken expired (30-day default), or a second token was issued for the same keyRefresh; one key per service
Behaviour changed without a deployAn admin edited the macro in the UIMacro definitions live outside your code

Migrating from V2

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
ElementV2V3Changed?
Path after version/macro/apply/macro/applyNo
assetClassRequired, String, 10 supported valuesIdenticalNo
entityKeysRequired, array of stringsIdenticalNo
macroIdsRequired, array of stringsIdenticalNo
HeadersAuthorization, Key, Content-Type, AcceptIdenticalNo
Success response204 No Content204 No ContentNo

Review existing integrations against the V3 API contract when migrating rather than assuming that all V2 and V3 behavior is identical.

Common tasks

Close out resolved cases from an external system

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.

Bulk-tag a campaign's assets

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.

Chain multiple macros

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.

Escalate on an external signal

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.


Best practices

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.