Give feedback for the page

HTTP API

Authentication / Account Management

Login

Create Auth TokenPost/me

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 in your apps and keys lookup.

Example URI

Post https://admin.pubnub.com/api/me
Request
HideShow
Headers
Content-Type: application/json
Body
{
    "email": "blocksUser@pubnub.com",
    "password": "verySecretPassword"
}
Response  200
HideShow
Body
{
    result: {
        created: 1464063983,
        expires: 1467594357,
        modified: 1465002357,
        token: "394f7dbd-f713-4a02-b1ca-17a258f5c9cc",
        user_id: 267180,
    }
}

Listing Applications

Listing ApplicationsGet/apps?owner_id=267180

Example URI

Get https://admin.pubnub.com/api/apps?owner_id=267180
URI Parameters
HideShow
owner_id
number (required) Example: 267180

return Keys for this application.

Request
HideShow
Headers
X-Session-Token: 394f7dbd-f713-4a02-b1ca-17a258f5c9cc
Response  200
HideShow

Listing Keys

List Keys by Application IDGet/keys?app_id=267180

Example URI

Get https://admin.pubnub.com/api/keys?app_id=267180
URI Parameters
HideShow
app_id
number (required) Example: 267180

return Keys for this application.

Request
HideShow
Headers
X-Session-Token: 394f7dbd-f713-4a02-b1ca-17a258f5c9cc
Response  200
HideShow

Block Operations

Show All

Listing Blocks GET/v1/blocks/key/178088/block

Example URI

GET https://admin.pubnub.com/api/v1/blocks/key/178088/block
URI Parameters
HideShow
keyId
number (required) Example: 178088

key id for which to fetch associated blocks

Request
HideShow
Headers
Content-Type: application/json
X-Session-Token: 394f7dbd-f713-4a02-b1ca-17a258f5c9cc
Response  200

Starting

StartingPOST/v1/blocks/key/178088/block/71/start

Example URI

POST https://admin.pubnub.com/api/v1/blocks/key/178088/block/71/start
URI Parameters
HideShow
keyId
number (required) Example: 178088

key which owns the block.

blockId
number (required) Example: 71

block id to start.

Request
HideShow
Headers
Content-Type: application/json
X-Session-Token: 394f7dbd-f713-4a02-b1ca-17a258f5c9cc
Response  200

Stopping

StoppingPOST/v1/blocks/key/178088/block/71/stop

Example URI

POST https://admin.pubnub.com/api/v1/blocks/key/178088/block/71/stop
URI Parameters
HideShow
keyId
number (required) Example: 178088

key which owns the block.

blockId
number (required) Example: 71

block id to stop.

Request
HideShow
Headers
Content-Type: application/json
X-Session-Token: 394f7dbd-f713-4a02-b1ca-17a258f5c9cc
Response  200

Event Handlers

Show All

Listing Event HandlersGET/v1/blocks/key/178088/block/71

Example URI

GET https://admin.pubnub.com/api/v1/blocks/key/178088/block/71
URI Parameters
HideShow
keyId
number (required) Example: 178088

key which owns the block.

blockId
number (required)  Example: 71

block id to list event handlers for.

Request
HideShow
Headers
Content-Type: application/json
X-Session-Token: 394f7dbd-f713-4a02-b1ca-17a258f5c9cc
Response  200

Creating Event Handler

Create Event HandlerPOST/v1/blocks/key/178088/event_handler

Be sure to reformat the code before uploading using the following snippet:

EH_FILE="event-handler.js"
  EVENT_HANDLER='cat $EH_FILE | sed "s/'/\\\'/g" | sed 's/"/\\\"/g' | sed 's/[\r\n]/\\n/g''

Example URI

POST https://admin.pubnub.com/api/v1/blocks/key/178088/event_handler
URI Parameters
HideShow
keyId
number (required) Example: 178088

key which owns the event handler.

Request
HideShow
Headers
Content-Type: application/json
X-Session-Token: 394f7dbd-f713-4a02-b1ca-17a258f5c9cc
Body
{
    "key_id": 178088,
    "block_id": 71,
    "channels": "blockChannel",
    "code": "console.log('hi')",
    "event": "js-before-publish",
    "log_level": "debug",
    "name": "blockName",
    "output": "output-0.5823105682419438"
}
Response  200

Updating Event Handler

Updating Event HandlerPUT/v1/blocks/key/178088/event_handler112

Be sure to reformat the code before uploading using the following snippet:

EH_FILE="event-handler.js"
  EVENT_HANDLER='cat $EH_FILE | sed "s/'/\\\'/g" | sed 's/"/\\\"/g' | sed 's/[\r\n]/\\n/g''

Example URI

PUT https://admin.pubnub.com/api/v1/blocks/key/178088/event_handler112
URI Parameters
HideShow
keyId
number (required) Example: 178088

key which owns the event handler.

eventHandlerId
number (required) Example: 112

id of event handler to be updated

Request
HideShow
Headers
Content-Type: application/json
X-Session-Token: 394f7dbd-f713-4a02-b1ca-17a258f5c9cc
Body
{
    "key_id": 178088,
    "block_id": 71,
    "event_handler_id": 112,
    "channels": "blockChannel",
    "code": "console.log('hi')",
    "event": "js-before-publish",
    "log_level": "debug",
    "name": "blockName",
    "output": "output-0.5823105682419438"
}
Response  200

Block Creation

CREATE Block

Create BlockPOST/api/v1/blocks/key/<key_id>/block

Body
{
"key_id": < key id>,
"name": "< name of the block>",
"description": "< description of the block>"
}

UPDATE Block

UPDATE BlockPUT/api/v1/blocks/key/<key_id>/block/<block_id>

Body
{
"key_id": < key id>,
"name": "< name of the block>",
"description": "< description of the block>"
}

DELETE Block

DELETE BlockDELETE/api/v1/blocks/key/<key id>/block/<block-id>

Body

Host: admin.pubnub.com
Connection: keep-alive
Origin: https://admin.pubnub.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36
Accept: application/json, text/plain, */*
X-Session-Token: 8944e0ed-ad2a-4154-8abd-005c5906266f
X-Requested-With: XMLHttpRequest
X-Portal: 02119f1055b08ae493846e4262429c060c452625
Referer: https://admin.pubnub.com/
Accept-Encoding: gzip, deflate, sdch, br
Accept-Language: en-US,en;q=0.8