POST
/
v1
/
campaigns
curl --request POST \
  --url https://api.castled.io/backend/external/v1/campaigns \
  --header 'Api-Key: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "my-campaign",
  "externalId": "<string>",
  "segment": {
    "query": "select * from users",
    "primaryKey": "user_id"
  },
  "schedule": {
    "type": "START_NOW",
    "startTs": 123
  },
  "message": {
    "type": "MOBILE_PUSH",
    "iosEnabled": true,
    "androidEnabled": true,
    "title": {
      "en": "Hey {{ first_name | '\''there'\'' }}",
      "hi": " हेलो {{ first_name | '\''there'\'' }}"
    },
    "subtitle": {},
    "body": {
      "en": "Hello from Castled!",
      "hi": "कैसल्ड की ओर से नमस्ते!"
    },
    "collapseId": "<string>",
    "ttl": 123,
    "action": "DEFAULT",
    "androidActionUrl": "<string>",
    "iosActionUrl": "<string>",
    "keyVals": {},
    "bigImageUrl": "<string>",
    "largeIconUrl": "<string>",
    "smallIconResourceId": "<string>",
    "androidChannel": "<string>",
    "priority": "NORMAL",
    "androidActionButtons": [
      {
        "label": "<string>",
        "url": "<string>",
        "clickAction": "DEEP_LINKING",
        "keyVals": {}
      }
    ],
    "soundFileName": "<string>",
    "richMediaUrl": "<string>",
    "mediaType": "IMAGE",
    "interruptionLevel": "PASSIVE",
    "badgeCount": 123,
    "relevanceScore": "SCORE_MAX",
    "contentAvailable": true,
    "actionCategory": {
      "type": "PREDEFINED_CATEGORY",
      "name": "<string>",
      "actionComponents": [
        {
          "actionId": "<string>",
          "url": "<string>",
          "clickAction": "DEEP_LINKING",
          "keyVals": {},
          "useWebview": true
        }
      ]
    }
  }
}'
{
  "uuid": "<string>"
}

Headers

Api-Key
string
required

Private key to access the API.

Body

application/json
Event data to be tracked.

Schema representing campaign create request data.

name
string
required

Name of the campaign

segment
object
required

Segment of users for whom campaign is being run

schedule
object
required

Campaign start schedule

message
object
required

Campaign message details.

externalId
string

Optional external id assigned to the campaign. Used to ensure idempotency, to prevent same campaign from being created more than once. Max length of 256 chars

Response

200 - application/json
Campaign successfully created

A standard response for successful campaign creation.

uuid
string

UUID of the created campaign