Permissions .: Create

API Reference / v15

Create a Permissions Request

Create a Permissions Request to take actions on an account based on the permissions keynames that are requested.

Request Endpoint

POST /v15/apps/permissions_requests

Authorization Required – App Token in Header

Authorization: token 123456-75489120749...

Request Body

{
  "permissions_request": {
    "email": "email@example.com",
    "permission_keynames": [
      "create_orders"
    ],
    "target_app_id": 1
  }
}

Request Parameters

Parameter Type Required Description
email String Yes The user’s email address
permission_keynames Array Yes Array of requested permissions
target_app_id Integer No ID of App which should receive push notification

The request for permissions will be created and approved or declined by the user. The result of the permission request will be POSTed back to your designated App Callback URL. To set your App Callback URL, please submit a support request.

Example Call

curl https://sandbox.thelevelup.com/v15/apps/permissions_requests \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: token 1061-c6b2aa0c3062c4c019ea08a1143c782c20b32467ad35faaa14e19d72c0ba68' \
  -d '{
    "permissions_request": {
      "email": "testcreds+consumer@thelevelup.com",
      "permission_keynames": [
        "create_orders"
      ],
      "target_app_id": 61
    }
  }'

Example Response

{
  "permissions_request": {
    "app_id": 20,
    "id": 1135,
    "permission_keynames": [
      "create_orders"
    ],
    "state": "pending"
  }
}

Response Parameters

Param Type Description
app_id Integer The LevelUp App ID
id Integer The LevelUp permission request ID
permission_keynames Array Types of permissions requested
state String State of request (Will be pending until the user approves or rejects the request)

After this call, the user will receive a notifcation to approve the requested permissions to your app. If they approve the app, the LevelUp API will POST a response to the URL of your choosing. To set your App POST URL, submit a support request. If you don’t have an endpoint ready but still want to receive the responses, we recommend utilizing our Permissions Request Show endpoint.

You will want to save the ID of the permissions request as you will use it to identify the POST response from LevelUp when the user accepts the permissions request:

{
  "permissions_request": {
    "id": 38,
    "state": "accepted",
    "token": "123456-75489120749..."
  }
}

Once you receive this POST, you can use the token to authorize relevant requests for that account.