Call the API with a token
Run plugin actions from a script or another server with an access token.
On this page
Scripts and other servers can call the API actions of your plugins without signing in. They send a token that you set in the file config.
1. Set the token
Add a token line to the file config, with a long random value of your own:
token : put-a-long-random-value-hereRestart Pluginable.
2. Call an action
Send a POST request to /admin/ with the token in the x-token header and the name of the action in schema. For example, the list of the sample Products plugin:
curl -X POST http://127.0.0.1:8000/admin/ \
-H 'content-type: application/json' \
-H 'x-token: put-a-long-random-value-here' \
-d '{"schema":"products"}'The answer is the JSON that the action returns. The name in schema is the one in the ROUTE line of the plugin, for example products in ROUTE('+API ? -products --> Products/list'). Actions that take data get it in a data field next to schema.
Keep it safe
A request with the token has full admin rights. Keep the token secret, use HTTPS, and leave the token line out of config when you do not need it.