> For the complete documentation index, see [llms.txt](https://docs.datasentinel.io/manual/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.datasentinel.io/manual/implementation/platform-usage/api-reference.md).

# API Reference

The REST API of the platform: how to authenticate, what each API covers, and where to find ready-to-use examples.

The platform API lets scripts and external tools do what the user interface does: declare connections, manage users and roles, generate reports, export metrics and drive alerting.

All routes start with `https://<<platform-server>>/ds-api`.

## How a call works

{% stepper %}
{% step %}

### Get an access token

Call the token route with a Datasentinel username and password.

```bash
curl -u myUser:myPassword -k -X POST https://<<platform-server>>/ds-api/user-token
```

The token is valid for 24 hours. See [Access Token](https://docs.datasentinel.io/manual/implementation/platform-usage/api-reference/access-token.md).
{% endstep %}

{% step %}

### Call the API with the token

Send the token in the `user-token` header of every call.
{% endstep %}

{% step %}

### Renew the token when it expires

After 24 hours, request a new token.
{% endstep %}
{% endstepper %}

## The APIs

| API                                                                                                             | Use it to                             | Main actions                                                                  |
| --------------------------------------------------------------------------------------------------------------- | ------------------------------------- | ----------------------------------------------------------------------------- |
| [Access Token](https://docs.datasentinel.io/manual/implementation/platform-usage/api-reference/access-token.md) | Authenticate                          | Create a token, display its owner and its expiry time                         |
| [Connection](https://docs.datasentinel.io/manual/implementation/platform-usage/api-reference/connection.md)     | Manage agentless connections          | Add, display, update, enable, disable, delete                                 |
| [Role](https://docs.datasentinel.io/manual/implementation/platform-usage/api-reference/role.md)                 | Define which instances a role can see | Add, display, replace, delete, list the assigned users                        |
| [User](https://docs.datasentinel.io/manual/implementation/platform-usage/api-reference/user.md)                 | Manage the users                      | Add, display, update, delete, assign or remove a role                         |
| [Reporting](https://docs.datasentinel.io/manual/implementation/platform-usage/api-reference/reporting.md)       | Generate PDF reports                  | One route per report type, and email delivery                                 |
| [Workload](https://docs.datasentinel.io/manual/implementation/platform-usage/api-reference/workload.md)         | Export metrics                        | Session history, queries, instances, tables, indexes, servers, in JSON or CSV |
| [Alerting](https://docs.datasentinel.io/manual/implementation/platform-usage/api-reference/alerting.md)         | Drive alerting for an instance        | Status, enable, disable, list the problems, create customized alerts          |

{% hint style="info" %}
The Connection API exists on on-premises installations only, and applies to the [agentless](https://docs.datasentinel.io/manual/features/other-features/agentless-monitoring.md) method. With local agents, a connection is added on the agent itself. See the [Agent API](https://docs.datasentinel.io/manual/implementation/agent-usage/api-reference.md).
{% endhint %}

## Common uses

| You want to                                           | API                                                                                                                                                                                                 |
| ----------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Declare many cloud instances at once                  | [Connection](https://docs.datasentinel.io/manual/implementation/platform-usage/api-reference/connection.md)                                                                                         |
| Create users and assign their roles from a script     | [User](https://docs.datasentinel.io/manual/implementation/platform-usage/api-reference/user.md) and [Role](https://docs.datasentinel.io/manual/implementation/platform-usage/api-reference/role.md) |
| Generate a report every night and send it by email    | [Reporting](https://docs.datasentinel.io/manual/implementation/platform-usage/api-reference/reporting.md)                                                                                           |
| Load Datasentinel metrics into another tool           | [Workload](https://docs.datasentinel.io/manual/implementation/platform-usage/api-reference/workload.md)                                                                                             |
| Silence an instance during a maintenance, then resume | [Alerting](https://docs.datasentinel.io/manual/implementation/platform-usage/api-reference/alerting.md)                                                                                             |
| Raise your own alert from an external check           | [Alerting](https://docs.datasentinel.io/manual/implementation/platform-usage/api-reference/alerting.md)                                                                                             |

## Ready-to-use examples

The [Datasentinel toolkit](https://github.com/datasentinel/datasentinel_toolkit) on GitHub provides shell scripts and Ansible playbooks that call these APIs: connections, bulk loading of connections, users, roles, reports and metric export.

It is pre-installed on the on-premises platform, in **`/datasentinel/soft/datasentinel_toolkit`**.

## Pages

{% content-ref url="/pages/pWMV9FXn2PVthWicFKyC" %}
[Access Token](https://docs.datasentinel.io/manual/implementation/platform-usage/api-reference/access-token.md)
{% endcontent-ref %}

{% content-ref url="/pages/QzfvS4NlK6uuNUarhtfv" %}
[Connection](https://docs.datasentinel.io/manual/implementation/platform-usage/api-reference/connection.md)
{% endcontent-ref %}

{% content-ref url="/pages/7OpT9RFUa8A64C7B8awR" %}
[Role](https://docs.datasentinel.io/manual/implementation/platform-usage/api-reference/role.md)
{% endcontent-ref %}

{% content-ref url="/pages/PEkFNsuq5YqVposp2CLG" %}
[User](https://docs.datasentinel.io/manual/implementation/platform-usage/api-reference/user.md)
{% endcontent-ref %}

{% content-ref url="/pages/Ax2GR2jf0dLwU2cYguRk" %}
[Reporting](https://docs.datasentinel.io/manual/implementation/platform-usage/api-reference/reporting.md)
{% endcontent-ref %}

{% content-ref url="/pages/rRbgcGgDFLK6tQGcDYOL" %}
[Workload](https://docs.datasentinel.io/manual/implementation/platform-usage/api-reference/workload.md)
{% endcontent-ref %}

{% content-ref url="/pages/lHR5nxUxOqS7JkbTcc00" %}
[Alerting](https://docs.datasentinel.io/manual/implementation/platform-usage/api-reference/alerting.md)
{% endcontent-ref %}

## See also

* [Agent API](https://docs.datasentinel.io/manual/implementation/agent-usage/api-reference.md): the API of the agents.
* [AI Connector](https://docs.datasentinel.io/manual/ai-connector): question the same metrics through an AI assistant.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.datasentinel.io/manual/implementation/platform-usage/api-reference.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
