---
title: Call the API with a token
project: Pluginable
version: 0.0.1
section: recipes
language: en
license: MIT
url: https://totaljs.es/docs/pluginable/0-0-1/recipes/api-token/
updated: 2026-11-19T07:46:16.797Z
---

# Call the API with a token

> Run plugin actions from a script or another server with an access token.

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:

```text
token       : put-a-long-random-value-here
```

Restart 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:

```bash
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.
