Functions API
You need a valid authentication token and an account ID to use the Functions API.
Calls which require email/password authentication won't work if the account used SSO to register with PubNub. Use the Forgot your password? link on the Admin Portal to set up a "new" password for the account and use it for PubNub API calls.
Create authentication token
Authenticate with an email and password to receive a session_token. The session token will be a top level key called token. The session token token is used for all requests after authentication. You also receive a user_id which is used to fetch an account ID.
Example URI
POST https://admin.pubnub.com/api/me
Request header
{
  "Content-Type": "application/json"
}
Request body
{
  "email": "blocksUser@pubnub.com",
  "password": "verySecretPassword"
}
Response body
{
  "result": {
    "created": 1464063983,
    "expires": 1467594357,
    "modified": 1465002357,
    "token": "39gjjhy5d-1337-4a02-0451-17a3222f5c9cc",
    "role": "user",
    "status": 1,
    "storage": null,
    "user": {
      "created": 1400972126,
      "email": "...",
      "id": 123456,
      "login_attempts": 0
    },
Example call
curl \
-H "Content-Type: application/json" \
-d '{
  "email": "blocksUser@pubnub.com",
  "password": "verySecretPassword"
}' \
-X POST \
"https://admin.pubnub.com/api/me"
Fetch account ID
This endpoint returns an array of accounts you are part of. Item at index 0 is your account. That account object has an ID field. You need to use this ID to query apps and keys endpoint where owner_id = account.id.
Example URI
GET https://admin.pubnub.com/api/accounts?user_id=123456
URI Parameters
user_id number (required)
Example: 123456
Use user_id received in the response
Request headers
{
  "Accept": "application/json",
  "X-Session-Token": "394f7dbd-f713-4a02-b1ca-17a234234f5c9cc"
}
Response body
{
  "result": {
    "accounts": [{
      "created": 1355425945,
      "dates": {
        "company": {
          "created": 1489708540,
          "modified": null
        }
      },
      "id": 267180,
      "modified": null,
      "owner_id": 123456,
      "properties": {
        "company": "home"
Example call
curl \
-H "Accept: application/json" \
-H "X-Session-Token: 394f7dbd-f713-4a02-b1ca-17234234f5c9cc" \
-X GET \
"https://admin.pubnub.com/api/accounts?user_id=123456"