Skip to main content

Staking API Webhooks - NEAR


API AuthenticationClick to view API Authentication details
API calls require authentication with API key via Authorization request header or URL property. Calls are made to one of the Near Staking API Webhooks endpoints found in your app's dashboard.

For example: https://near-slate.datahub.figment.io

Here's some boilerplate to get you started.
fetch("https://near-slate.datahub.figment.io/api/v1/webhook_endpoints", {
method: 'POST', // can also be 'GET', 'PUT' or any appropriate method
headers: {
"Authorization" : "<api_key>",
"Content-Type": "application/json" // if method is 'POST'
},
body: JSON.stringify({
// JSON Payload
})
})

Available Methods

Create New Webhook Endpoint

Create a new webhook endpoint with the specified parameters

Request Body
Example Response
{
"id": 17,
"event_types": [
"*"
],
"target_url": "https://example.com/my/endpoint",
"enabled": false,
"object": "webhook_endpoint",
"created": "2022-08-15T19:09:37.964Z",
"secret": "whsec_xjCyVJZFjPBfmPh3joth3q4xsa9YJnL7vpSDdijfxYdMmHFtMxcXueudsGYgYYkb4wEnFMq18M5yZnUsNMQJkXkS9fXa1tZbc2Xk"
}
SpecificationView Specification

Parameters

  • webhook_endpoint - object
  • target_url - string The target URL to send the webhook to.
  • event_types - string Can be a specific event type, or use an asterisk as a catchall: ['*']
  • enabled - boolean true / false

Response

  • id - number Id of the newly created webhook endpoint.
  • event_types - string Event type you have passed in the request parameter.
  • target_url - string The target URL to send the webhook to.
  • enabled - boolean true / false
  • object - string webhook_endpoint
  • created - string Timestamp when webhook endpoint was created.
  • secret - string Unique string for your webhook endpoint.

Note

  • Each webhook is identified by a sequential number.
  • Currently when a webhook ID has been deleted it cannot be reused.
  • You will only be provided with the secret when you first create a webhook. Remember to capture this data!

Retrieve Endpoint

Retrieve the details of a webhook endpoint.

Request Query
Example Response
{
"id": 17,
"event_types": [
"*"
],
"target_url": "https://example.com/my/endpoint",
"enabled": false,
"object": "webhook_endpoint",
"created": "2022-08-15T19:09:37.964Z"
}
SpecificationView Specification

Parameters

  • For Individual Webhook Endpoint
  • Include the webhook ID number in the request URL, to retreive details for an individual webhook endpoint.
  • For All Webhook Endpoints
  • None

Response

  • object - string list
  • url - string Endpoint url
  • has_more - boolean true / false
  • data - object
  • id - number Id of the newly created webhook endpoint.
  • event_types - string Event type you have passed in the request parameter.
  • target_url - string The target URL to send the webhook to.
  • enabled - boolean true / false
  • object - string webhook_endpoint
  • created - string Timestamp when webhook endpoint was created.

List Endpoints

Get the list of all your webhook endpoints.

Request Query
Example Response
{
"object": "list",
"url": "/api/v1/webhook_endpoints",
"has_more": false,
"data": [
{
"id": 18,
"event_types": [
"*"
],
"target_url": "https://example.com/my/endpoint",
"enabled": false,
"object": "webhook_endpoint",
"created": "2022-08-15T19:10:01.408Z"
},
{
"id": 17,
"event_types": [
"*"
],
"target_url": "https://example.com/my/new/endpoint",
"enabled": true,
"object": "webhook_endpoint",
"created": "2022-08-15T19:09:37.964Z"
}
]
}
SpecificationView Specification

Parameters

None

Response

  • object - string - The action, i.e., list.
  • url - string The endpoint URL.
  • has_more - boolean
  • data - array - An array of objects containing the details for each webhook:
    • id - number Id of the newly created webhook endpoint.
    • event_types - string Event type you have passed in the request parameter.
    • target_url - string The target URL to send the webhook to.
    • enabled - boolean true / false
    • object - string - Describing the data object: webhook_endpoint.
    • created - string Timestamp when the webhook endpoint was created.

Update Webhook Endpoint

Update details for an existing webhook endpoint.

Request Body
Example Response
{
"id": 17,
"event_types": [
"*"
],
"target_url": "https://example.com/my/new/endpoint",
"enabled": true,
"object": "webhook_endpoint",
"created": "2022-08-15T19:09:37.964Z"
}
SpecificationView Specification

Parameters

  • webhook_endpoint - object
  • target_url - string The target URL to send the webhook to.
  • event_types - string Can be a specific event type, or use an asterisk as a catchall: ['*']
  • enabled - boolean true / false

Response

  • id - number Id of the newly created webhook endpoint.
  • event_types - string Event type you have passed in the request parameter.
  • target_url - string The target URL to send the webhook to.
  • enabled - boolean true / false
  • object - string webhook_endpoint
  • created - string Timestamp when webhook endpoint was created.

Delete an Existing Endpoint

Delete a webhook endpoint

Request Query
Example Response
""
SpecificationView Specification

Parameters

Include the webhook ID number in the request URL, to delete webhook endpoint.

Response

None - 204 - No Content