SalesOS

After Save Triggers

Serverless functions that run synchronously after a record is saved (post-commit; failures are warnings)

List

GET
/v1/after-save-triggers

Authorization

AuthorizationRequiredBearer <token>

Session token from the SalesOS web app.

In: header

X-API-Key<token>

API key from Settings → API Keys. Authorization: ApiKey <key> is also accepted. Each operation lists the scope it needs under x-api-key-scopes.

In: header

curl -X GET "https://api.salesos.org/v1/after-save-triggers" \
  -H "Authorization: Bearer <token>"

AfterSaveTriggerArray

[
  {
    "id": "string",
    "organizationId": "string",
    "name": "string",
    "description": "string",
    "objectType": "string",
    "operations": [
      "string"
    ],
    "functionId": "string",
    "timeoutMs": 0,
    "position": 0,
    "isActive": true,
    "createdById": "string",
    "lastInvokedAt": "2019-08-24T14:15:22Z",
    "createdAt": "2019-08-24T14:15:22Z",
    "updatedAt": "2019-08-24T14:15:22Z"
  }
]

Run a function after every matching save

POST
/v1/after-save-triggers

Authorization

AuthorizationRequiredBearer <token>

Session token from the SalesOS web app.

In: header

X-API-Key<token>

API key from Settings → API Keys. Authorization: ApiKey <key> is also accepted. Each operation lists the scope it needs under x-api-key-scopes.

In: header

Request Body

application/jsonRequired
nameRequiredstring
Maximum length: 120
descriptionstring
Maximum length: 1000
objectTypeRequiredstring

LEAD | CONTACT | ACCOUNT | OPPORTUNITY | TASK | CASE | custom:

operationsRequiredarray<array<string>>
functionIdRequiredstring

The serverless function to run

timeoutMsnumber
Default: 5000Minimum: 250Maximum: 10000
positionnumber

Triggers on the same object run in ascending order

Minimum: 0Maximum: 1000
isActiveboolean
curl -X POST "https://api.salesos.org/v1/after-save-triggers" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Sync to ERP",
    "description": "string",
    "objectType": "OPPORTUNITY",
    "operations": [
      [
        "CREATE",
        "UPDATE"
      ]
    ],
    "functionId": "string",
    "timeoutMs": 5000,
    "position": 1000,
    "isActive": true
  }'

AfterSaveTrigger

{
  "id": "string",
  "organizationId": "string",
  "name": "string",
  "description": "string",
  "objectType": "string",
  "operations": [
    "string"
  ],
  "functionId": "string",
  "timeoutMs": 0,
  "position": 0,
  "isActive": true,
  "createdById": "string",
  "lastInvokedAt": "2019-08-24T14:15:22Z",
  "createdAt": "2019-08-24T14:15:22Z",
  "updatedAt": "2019-08-24T14:15:22Z"
}

Get

GET
/v1/after-save-triggers/{id}

Authorization

AuthorizationRequiredBearer <token>

Session token from the SalesOS web app.

In: header

X-API-Key<token>

API key from Settings → API Keys. Authorization: ApiKey <key> is also accepted. Each operation lists the scope it needs under x-api-key-scopes.

In: header

Path Parameters

idRequiredstring
curl -X GET "https://api.salesos.org/v1/after-save-triggers/<string>" \
  -H "Authorization: Bearer <token>"

AfterSaveTrigger

{
  "id": "string",
  "organizationId": "string",
  "name": "string",
  "description": "string",
  "objectType": "string",
  "operations": [
    "string"
  ],
  "functionId": "string",
  "timeoutMs": 0,
  "position": 0,
  "isActive": true,
  "createdById": "string",
  "lastInvokedAt": "2019-08-24T14:15:22Z",
  "createdAt": "2019-08-24T14:15:22Z",
  "updatedAt": "2019-08-24T14:15:22Z"
}

Update

PATCH
/v1/after-save-triggers/{id}

Authorization

AuthorizationRequiredBearer <token>

Session token from the SalesOS web app.

In: header

X-API-Key<token>

API key from Settings → API Keys. Authorization: ApiKey <key> is also accepted. Each operation lists the scope it needs under x-api-key-scopes.

In: header

Request Body

application/jsonRequired
namestring
Maximum length: 120
descriptionstring
Maximum length: 1000
objectTypestring

LEAD | CONTACT | ACCOUNT | OPPORTUNITY | TASK | CASE | custom:

operationsarray<string>

Items: at least 1.

functionIdstring

The serverless function to run

timeoutMsnumber
Default: 5000Minimum: 250Maximum: 10000
positionnumber

Triggers on the same object run in ascending order

Minimum: 0Maximum: 1000
isActiveboolean

Path Parameters

idRequiredstring

Header Parameters

Idempotency-Keystring

Unique key (a UUID is ideal) that makes this write safe to retry for 24 hours: a retry with the same body replays the original response (Idempotent-Replayed: true); the same key with a different body is a 409.

Maximum length: 255
curl -X PATCH "https://api.salesos.org/v1/after-save-triggers/<string>" \
  -H "Idempotency-Key: <string>" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Sync to ERP",
    "description": "string",
    "objectType": "OPPORTUNITY",
    "operations": [
      "CREATE",
      "UPDATE"
    ],
    "functionId": "string",
    "timeoutMs": 5000,
    "position": 1000,
    "isActive": true
  }'

AfterSaveTrigger

{
  "id": "string",
  "organizationId": "string",
  "name": "string",
  "description": "string",
  "objectType": "string",
  "operations": [
    "string"
  ],
  "functionId": "string",
  "timeoutMs": 0,
  "position": 0,
  "isActive": true,
  "createdById": "string",
  "lastInvokedAt": "2019-08-24T14:15:22Z",
  "createdAt": "2019-08-24T14:15:22Z",
  "updatedAt": "2019-08-24T14:15:22Z"
}

Remove

DELETE
/v1/after-save-triggers/{id}

Authorization

AuthorizationRequiredBearer <token>

Session token from the SalesOS web app.

In: header

X-API-Key<token>

API key from Settings → API Keys. Authorization: ApiKey <key> is also accepted. Each operation lists the scope it needs under x-api-key-scopes.

In: header

Path Parameters

idRequiredstring
curl -X DELETE "https://api.salesos.org/v1/after-save-triggers/<string>" \
  -H "Authorization: Bearer <token>"

DeletedResponse

{
  "deleted": true
}

Run the function with a sample record (its own salesos.* writes are real)

POST
/v1/after-save-triggers/{id}/test

Authorization

AuthorizationRequiredBearer <token>

Session token from the SalesOS web app.

In: header

X-API-Key<token>

API key from Settings → API Keys. Authorization: ApiKey <key> is also accepted. Each operation lists the scope it needs under x-api-key-scopes.

In: header

Request Body

application/jsonRequired
operationstring
Value in: "CREATE" | "UPDATE" | "DELETE"
recordobject

Sample saved record

previousobject

Sample previous record (updates)

Path Parameters

idRequiredstring

Header Parameters

Idempotency-Keystring

Unique key (a UUID is ideal) that makes this write safe to retry for 24 hours: a retry with the same body replays the original response (Idempotent-Replayed: true); the same key with a different body is a 409.

Maximum length: 255
curl -X POST "https://api.salesos.org/v1/after-save-triggers/<string>/test" \
  -H "Idempotency-Key: <string>" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "CREATE",
    "record": {},
    "previous": {}
  }'

AfterSaveTestResult

{
  "invocationId": "string",
  "ok": true,
  "status": "string",
  "output": {},
  "errorCode": "string",
  "errorMessage": "string",
  "durationMs": 0,
  "requestBody": {}
}