Making requests

All API requests must be made to https://api.leanplum.com/api. The API is very flexible and supports GET and POST request formats. Our docs, generally, use POST examples for methods that might update/change Leanplum data (e.g. start or setUserAttributes), but both GET and POST request methods are acceptable.

Request formats

GET

The top-level arguments are sent as GET parameters in the request. As part of the HTTP specification, a URL must be at most 2,083 characters, so it's best for small API requests. All characters in the URL should be URL encoded.

Example:

https://api.leanplum.com/api?appId=APP_ID&clientKey=CLIENT_KEY&apiVersion=1.0.6&userId=USER_ID&action=setUserAttributes&userAttributes={"Interests":["Technology","Music"]}

Properly encoded this is:

https://api.leanplum.com/api?appId=APP_ID&clientKey=CLIENT_KEY&apiVersion=1.0.6&userId=USER_ID&action=setUserAttributes&userAttributes=%7B%27Interests%27%3A+%5B%27Technology%27%2C+%27Music%27%5D%7D

POST

The top-level arguments can be either in the URL or in the request body. Generally, our docs show the action argument set in the URL for POST requests, but this is not necessary; all arguments can be set in the POST body with the request sent to https://api.leanplum.com/api. Alternatively, more (even all) arguments can be placed in the URL. However, all characters in the URL should be URL encoded.

📘

The Content-Type of the POST request must be JSON or multipart form data.

Example of a POST request with JSON:

POST https://api.leanplum.com/api?action=setUserAttributes

Content-Type: application/json
{
  "appId": "APP_ID",
  "clientKey": "CLIENT_KEY",
  "apiVersion": "1.0.6",
  "userId": "USER_ID",
  "userAttributes": {
    "Interests": [
      "Technology",
      "Music"
    ]
  }
}

Multiple actions can be batched together. It's highly recommended to batch API actions, especially for the same user. Do not make multiple concurrent API requests for the same user. See Batching requests for more.