# Authentication

The Violet API uses a **JWT-based authentication system** with refresh tokens to provide secure, long-term access to your applications. This system ensures your credentials remain secure while providing seamless API access.

#### Key Concepts

* **App Credentials**: `X-Violet-App-Id` and `X-Violet-App-Secret` identify your application
* **Authentication Token**: Short-lived JWT token (24 hours) for API requests
* **Refresh Token**: Long-lived token for obtaining new authentication tokens
* **Environment Separation**: Different credentials for test and production environments

{% @mermaid/diagram content="sequenceDiagram
participant App as Your Application
participant Violet as Violet API
participant Dashboard as Channel Dashboard

```
Note over App,Dashboard: Initial Setup
App->>Dashboard: Create account & application
Dashboard-->>App: App ID & App Secret

Note over App,Violet: Initial Authentication
App->>Violet: POST /login<br/>(credentials + headers)
Violet-->>App: Authentication Token + Refresh Token

Note over App,Violet: API Requests
App->>Violet: API Request<br/>(with auth token)
Violet-->>App: API Response

Note over App,Violet: Token Refresh (before expiry)
App->>Violet: GET /auth/token<br/>(with refresh token)
Violet-->>App: New Authentication Token

Note over App,Violet: Continued API Usage
App->>Violet: API Request<br/>(with new auth token)
Violet-->>App: API Response" %}
```


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.violet.io/concepts/overview.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
