Webhooks
Manually create the following endpoints on your API.
AdminX will call these to retrieve your data.
Introduction
- These webhooks are designed following a flavour of REST specification.
- Successful responses should return status code
200 OK
- Failed responses due to bad parametrization should return status code
404 Bad Request
- Failed responses due to internal errors should return status code
500 Internal Server Error
- Failed authentication responses should return status code
401 Unauthorized
and not provide any response payload. - Your server should respond to CORS pre-flight requests with the following headers:
- Access-Control-Allow-Credentials: true
- Access-Control-Allow-Headers:
content-type,adminx-data-auth-token
- Access-Control-Allow-Methods:
GET, POST, PUT, DELETE, OPTIONS, HEAD
- Access-Control-Allow-Origin:
https://adminx.io
- Object parameters are passed in the request payload for both requests and responses
- Non-object parameters are passed as query string for requests
Authentication 🔑
Authentication happens through the header adminx-data-auth-token
.
We recommend you store in an environment variable the ADMINX_DATA_AUTH_TOKEN configured in your AdminX Panel.
On every request, check the adminx-data-auth-token
header against it before progressing with the logic of the request.
If the DataAuthToken doesn’t match, return a 401 Unauthorized
.
BETA | Authentication is due to improvements in the near future, but we will keep supporting this implementation.
List of routes
Route | Parameters | Returns |
---|---|---|
/adminx/app/config | Array of schema config | |
/adminx/item/list | schema, search, sort, page, limit | Array of item |
/adminx/item/create | schema, item | item |
/adminx/item/read | schema, id | item |
/adminx/item/update | schema, id, item | item |
/adminx/item/delete | schema, id | item |
/adminx/item/action | schema, id, item, action | item |
GET /adminx/app/config
Get list of schema
objects.
Each schema respresents the structure of a model in your ORM or table in your database.
It also has AdminX configuration used to display and edit your data.
Request method
GET
Request headers
adminx-data-auth-token
Request parameters
none
Returns
✅ 200 OK
JSON Object with property “schemas” of type schema
{
"schemas": [
{
"key": "brand",
"name": "Brand",
"attrs": {
"id": {
"type": "integer",
"autoIncrement": true,
"primaryKey": true,
"unique": true,
"disabled": true
},
"name": {
"type": "string",
"list": true
},
"createdAt": {
"type": "datetime",
"default": "NOW"
},
"updatedAt": {
"type": "datetime",
"default": "NOW"
}
},
"actions": {}
},
{
"key": "car",
"name": "Car",
"attrs": {
"id": {
"type": "integer",
"autoIncrement": true,
"primaryKey": true,
"unique": true,
"disabled": true
},
"thumbnail": {
"type": "string",
"list": true,
"editor": "image"
},
"brand": {
"model": "brand"
},
"model": {
"type": "string",
"list": true
},
"summary": {
"type": "mediumtext"
},
"cover": {
"type": "string",
"editor": "image"
},
"history": {
"type": "longtext",
"editor": "html-simple"
},
"updatedAt": {
"type": "datetime",
"default": "NOW",
"list": true
},
"year": {
"type": "integer",
"min": 2000,
"max": 2019
},
"dailyRate": {
"type": "float",
"min": 0
},
"availableAt": {
"type": "date"
},
"fullTank": {
"type": "boolean"
},
"extras": {
"type": "array"
},
"doorConfiguration": {
"type": "string",
"enum": [
"2 Doors",
"3 Doors",
"4 Doors",
"5 Doors",
"6 Doors"
]
},
"metaData": {
"type": "json"
},
"createdAt": {
"type": "datetime",
"default": "NOW"
}
},
"actions": {}
}
]
}
GET /adminx/item/list
Get a list of items of type schema
filtered by search
, sort
, page
, limit
Request method
GET
Request headers
adminx-data-auth-token
Request parameters
Name | Type | Example |
---|---|---|
schema | String | car |
search | String | tesla |
sort | String | updatedAt asc |
page | Integer (>= 1) | 1 |
limit | Integer (>= 1) | 10 |
Returns
✅ 200 OK
JSON Object with propertyitems
an array of objects of type schema
pageIndex
a number of the current pagepageTotal
a number of total pages given the current filters
BETA | For performance reasons, our list component does not render populated associations right now. Hence, for each item, its associations should not be populated. This is subject to change in the future.
{
"items": [
{
"id": 3,
"model": "Model X",
"year": 2019,
"dailyRate": 99.95,
"availableAt": "2019-05-11T22:00:00.000Z",
"fullTank": true,
"summary": "Beautiful model X hand-crafted by Elon Musk",
"thumbnail": "//adminx-demo-image-production.s3.amazonaws.com/car/tesla-model-x-display.jpg",
"cover": "//adminx-demo-image-production.s3.amazonaws.com/car/tesla-model-x-cover.jpg",
"extras": [
"Google Maps",
"Bluetooth",
"PayPal"
],
"doorConfiguration": "5 Doors",
"history": "<i>(From Wikipedia)</i><br>",
"createdAt": "2017-11-05T17:00:01.024Z",
"updatedAt": "2017-11-05T17:00:01.049Z",
"brand": 1
},
{
"id": 2,
"model": "Mini Cooper",
"year": 2016,
"dailyRate": 32.21,
"availableAt": "2018-06-29T00:00:00.000Z",
"fullTank": false,
"summary": "The Mini Hatch, stylized as MINI hatch or MINI Hardtop in the US, also known as Mini Cooper or Mini One or simply the Mini, is a three-door hatchback first introduced in late 2000, with a second generation launched in 2006 and a third generation model launched in 2014. A convertible version was introduced in 2004, with the second generation following in 2008.",
"thumbnail": "//adminx-demo-image-production.s3.amazonaws.com/car/mini-cooper-display.jpg",
"cover": "//adminx-demo-image-production.s3.amazonaws.com/car/mini-cooper-cover.jpg",
"extras": [
"Bluetooth",
"Assisted Drive"
],
"doorConfiguration": "5 Doors",
"history": "<i>(From Wikipedia)</i><br>The Mini is a small economy car produced by the English based British Motor Corporation (BMC) and its successors from 1959 until 2000. The original is considered an icon of 1960s British popular culture.[8][9][10][11] Its space-saving transverse engine front-wheel drive layout – allowing 80 percent of the area of the car's floorpan to be used for passengers and luggage – influenced a generation of car makers.[12] In 1999 the Mini was voted the second most influential car of the 20th century, behind the Ford Model T, and ahead of the Citroën DS and Volkswagen Beetle.[13][14] This distinctive two-door car was designed for BMC by Sir Alec Issigonis. It was manufactured at the Longbridge and Cowley plants in England, the Victoria Park/Zetland British Motor Corporation (Australia) factory in Sydney, Australia, and later also in Spain (Authi), Belgium, Chile, Italy (Innocenti), Malta, Portugal, South Africa, Uruguay, Venezuela and Yugoslavia. The Mini Mark I had three major UK updates – the Mark II, the Clubman and the Mark III. Within these was a series of variations, including an estate car, a pick-up truck, a van and the Mini Moke, a jeep-like buggy.",
"createdAt": "2017-11-05T17:00:01.024Z",
"updatedAt": "2017-11-05T17:00:01.046Z",
"brand": 2
},
{
"id": 1,
"model": "Frontier",
"year": 2017,
"dailyRate": 45.95,
"availableAt": "2018-10-29T00:00:00.000Z",
"fullTank": true,
"summary": "The Nissan Navara is the name for the D22 and D40 generations of Nissan pickup trucks sold in Asia and Europe; and the name for all generations of the vehicles in Australia. In North, Central and South America it is sold as the Nissan Frontier.",
"thumbnail": "//adminx-demo-image-production.s3.amazonaws.com/car/nissan-frontier-display.jpg",
"cover": "//adminx-demo-image-production.s3.amazonaws.com/car/nissan-frontier-cover.jpg",
"extras": [
"4x4",
"Bluetooth",
"Wi-Fi"
],
"doorConfiguration": "5 Doors",
"history": "<i>(From Wikipedia)</i><br>The Nissan Navara is the name for the D22 and D40 generations of Nissan pickup trucks sold in Asia and Europe; and the name for all generations of the vehicles in Australia. In North, Central and South America it is sold as the Nissan Frontier.",
"createdAt": "2017-11-05T17:00:01.023Z",
"updatedAt": "2017-11-05T17:00:01.045Z",
"brand": 3
}
],
"pageIndex": 0,
"pageTotal": 1
}
POST /adminx/item/create
Create an item of type schema
Request method
POST
Request headers
adminx-data-auth-token
Request parameters
Name | Type | Example |
---|---|---|
schema | String | car |
item | Object | { model: ‘Model X’, brand: { id: 13, name: ‘Tesla’ } } |
BETA | Associations are sent populated, this is subject to change in the future.
{
"item": {
"brand": {
"id": 1,
"name": "Tesla",
"createdAt": "2017-11-05T17:20:00.016Z",
"updatedAt": "2017-11-05T17:20:00.016Z"
},
"model":"Model X"
}
}
Returns
✅ 200 OK
JSON Object of type schema
{
"id": 3,
"brand": 1,
"model": "Model X",
"createdAt": "2017-11-05T17:27:18.930Z",
"updatedAt": "2017-11-05T17:27:18.930Z"
}
GET /adminx/item/read
Get an item of type schema
by id
Request method
GET
Request headers
adminx-data-auth-token
Request parameters
Name | Type | Example |
---|---|---|
schema | String | car |
id | String | 3 |
Returns
✅ 200 OK
JSON Object of type schema
BETA | Associations must be returned populated, this is subject to change in the future.
{
"id": 3,
"model": "Model X",
"year": 2019,
"dailyRate": 99.95,
"availableAt": "2019-05-11T22:00:00.000Z",
"fullTank": true,
"summary": "Beautiful model X hand-crafted by Elon Musk",
"thumbnail": "//adminx-demo-image-production.s3.amazonaws.com/car/tesla-model-x-display.jpg",
"cover": "//adminx-demo-image-production.s3.amazonaws.com/car/tesla-model-x-cover.jpg",
"extras": [
"Google Maps",
"Bluetooth",
"PayPal"
],
"doorConfiguration": "5 Doors",
"history": "<i>(From Wikipedia)</i><br>",
"createdAt": "2017-11-05T17:30:00.050Z",
"updatedAt": "2017-11-05T17:30:00.084Z",
"brand": {
"id": 1,
"name": "Tesla",
"createdAt": "2017-11-05T17:30:00.030Z",
"updatedAt": "2017-11-05T17:30:00.030Z"
}
}
POST /adminx/item/update
Update an item of type schema
by id
with new data item
Request method
POST
Request headers
adminx-data-auth-token
Request parameters
Name | Type | Example |
---|---|---|
schema | String | car |
id | String | 3 |
item | Object | { model: ‘Model 007’ […] } |
BETA | Associations are sent populated. Also the full model is sent, not just the attributes that changed. This is subject to change in the future.
{
"item": {
"id": 3,
"model": "Model 007",
"year": 2019,
"dailyRate": 99.95,
"availableAt": "2019-05-11T22:00:00.000Z",
"fullTank": true,
"summary": "Beautiful model X hand-crafted by Elon Musk",
"thumbnail": "//adminx-demo-image-production.s3.amazonaws.com/car/tesla-model-x-display.jpg",
"cover": "//adminx-demo-image-production.s3.amazonaws.com/car/tesla-model-x-cover.jpg",
"extras": [
"Google Maps",
"Bluetooth",
"PayPal"
],
"doorConfiguration": "5 Doors",
"history": "<i>(From Wikipedia)</i><br>",
"createdAt": "2017-11-05T17:40:00.043Z",
"updatedAt": "2017-11-05T17:40:00.061Z",
"brand": {
"id": 1,
"name": "Tesla",
"createdAt": "2017-11-05T17:40:00.019Z",
"updatedAt": "2017-11-05T17:47:06.413Z"
}
}
}
Returns
✅ 200 OK
JSON Object of type schema
with updated values of item
{
"id": 3,
"model": "Model X",
"year": 2019,
"dailyRate": 99.95,
"availableAt": "2019-05-11T22:00:00.000Z",
"fullTank": true,
"summary": "Beautiful model X hand-crafted by Elon Musk",
"thumbnail": "//adminx-demo-image-production.s3.amazonaws.com/car/tesla-model-x-display.jpg",
"cover": "//adminx-demo-image-production.s3.amazonaws.com/car/tesla-model-x-cover.jpg",
"extras": [
"Google Maps",
"Bluetooth",
"PayPal"
],
"doorConfiguration": "5 Doors",
"history": "<i>(From Wikipedia)</i><br>",
"createdAt": "2017-11-05T17:40:00.043Z",
"updatedAt": "2017-11-05T17:47:25.882Z",
"brand": {
"id": 1,
"name": "Tesla",
"createdAt": "2017-11-05T17:40:00.019Z",
"updatedAt": "2017-11-05T17:47:25.865Z"
}
}
POST /adminx/item/delete
Delete an item of type schema
by id
Request method
POST
Request headers
adminx-data-auth-token
Request parameters
Name | Type | Example |
---|---|---|
schema | String | car |
id | String | 3 |
Returns
✅ 200 OK
JSON Object of type schema
which has just been deleted
BETA | Associations are not populated. This is subject to change in the future.
{
"id": 3,
"model": "Model X",
"year": 2019,
"dailyRate": 99.95,
"availableAt": "2019-05-11T22:00:00.000Z",
"fullTank": true,
"summary": "Beautiful model X hand-crafted by Elon Musk",
"thumbnail": "//adminx-demo-image-production.s3.amazonaws.com/car/tesla-model-x-display.jpg",
"cover": "//adminx-demo-image-production.s3.amazonaws.com/car/tesla-model-x-cover.jpg",
"extras": [
"Google Maps",
"Bluetooth",
"PayPal"
],
"doorConfiguration": "5 Doors",
"history": "<i>(From Wikipedia)</i><br>",
"createdAt": "2017-11-05T18:00:00.069Z",
"updatedAt": "2017-11-05T18:00:00.105Z",
"brand": 1
}
POST /adminx/item/action
Execute custom action over item of type schema
with id
and current data item
Request method
POST
Request headers
adminx-data-auth-token
Request parameters
Name | Type | Example |
---|---|---|
schema | String | car |
id | String | 3 |
item | Object | { history: ‘nothing’ […] } |
action | String | fetchHistoryFromWiki |
In this example we want to call a custom action fetchHistoryFromWiki
which will fetch the history
of the car based on its model
attribute and return an updated car.
{
"item": {
"id": 3,
"model": "Model X",
"year": 2019,
"dailyRate": 99.95,
"availableAt": "2019-05-11T22:00:00.000Z",
"fullTank": true,
"summary": "Beautiful model X hand-crafted by Elon Musk",
"thumbnail": "//adminx-demo-image-production.s3.amazonaws.com/car/tesla-model-x-display.jpg",
"cover": "//adminx-demo-image-production.s3.amazonaws.com/car/tesla-model-x-cover.jpg",
"extras": [
"Google Maps",
"Bluetooth",
"PayPal"
],
"doorConfiguration": "5 Doors",
"history": "<i>(From Wikipedia)</i><br>",
"createdAt": "2017-11-05T18:07:31.902Z",
"updatedAt": "2017-11-05T18:09:22.391Z",
"brand": {
"id": 1,
"name": "Tesla",
"createdAt": "2017-11-05T18:07:31.859Z",
"updatedAt": "2017-11-05T18:09:22.330Z"
}
}
}
Returns
✅ 200 OK
JSON Object of type schema
with updated values after executing action
BETA | Actions in general are an experimental feature. Please don’t overuse them for now. If you want to rely heavily on actions feel free to shoot us an email at [email protected] so we can advise on how they might change in the future.
{
"item": {
"id": 3,
"model": "Model X",
"year": 2019,
"dailyRate": 99.95,
"availableAt": "2019-05-11T22:00:00.000Z",
"fullTank": true,
"summary": "Beautiful model X hand-crafted by Elon Musk",
"thumbnail": "//adminx-demo-image-production.s3.amazonaws.com/car/tesla-model-x-display.jpg",
"cover": "//adminx-demo-image-production.s3.amazonaws.com/car/tesla-model-x-cover.jpg",
"extras": [
"Google Maps",
"Bluetooth",
"PayPal"
],
"doorConfiguration": "5 Doors",
"history": "<i>(From Wikipedia)</i><br>The Tesla Model X is a mid-sized, all-electric, luxury, crossover SUV made by Tesla, Inc. that uses falcon wing doors for access to the second and third row seats.",
"createdAt": "2017-11-05T18:07:31.902Z",
"updatedAt": "2017-11-05T18:09:22.391Z",
"brand": {
"id": 1,
"name": "Tesla",
"createdAt": "2017-11-05T18:07:31.859Z",
"updatedAt": "2017-11-05T18:09:22.330Z"
}
}
}