> ## Documentation Index
> Fetch the complete documentation index at: https://developers.jobhandy.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Create and manage API keys

> Create, scope, deactivate, reactivate, rotate, and delete JobHandy API keys in the administration portal.

API keys are managed in the JobHandy administration portal. This page explains who can manage credentials, how scope is assigned, and how access is revoked or restored.

<Info>
  Open [JobHandy Administration](https://app.jobhandy.io/admin). API key management requires at least one of these portal permissions: **IT**, **HR**, or **Company-Admin**.
</Info>

## Permission models

Portal permissions and API-key scope are separate controls:

| Control           | Applies to                    | Purpose                                                           |
| ----------------- | ----------------------------- | ----------------------------------------------------------------- |
| Portal permission | A signed-in JobHandy user     | Determines who may open IT Settings and manage keys               |
| API-key scope     | A server-to-server credential | Determines which tenants and divisions the integration may access |

A user who may create a key does not automatically grant that key access to every company. The scope selected during creation is the effective API boundary.

## Open API key management

In the administration portal, open **IT Settings** and select the **API Keys** tab. The table shows each key's name, scope, status, creation date, and available actions.

<Frame>
  <img src="https://mintcdn.com/jobhandy/eYWivtukLSxRL1Cd/images/api-keys/api-key-list-en.png?fit=max&auto=format&n=eYWivtukLSxRL1Cd&q=85&s=cb10c95ce69e6fb33416303439a3f3f3" alt="JobHandy IT Settings with the API Keys tab, existing API keys, and the Create API Key button" width="1224" height="785" data-path="images/api-keys/api-key-list-en.png" />
</Frame>

## Create an API key

Click **Create API Key** and enter a descriptive name for the consuming system or integration.

Recommended naming pattern:

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
<System>-<Purpose>-<Environment>
```

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
HR-Middleware-Employee-Sync-Production
Payroll-Connector-Exports-Production
```

Next, define the companies and divisions the key may access.

<Frame>
  <img src="https://mintcdn.com/jobhandy/eYWivtukLSxRL1Cd/images/api-keys/api-key-create-en.png?fit=max&auto=format&n=eYWivtukLSxRL1Cd&q=85&s=6b8e0ddc65b1949165d449bc9c19ab48" alt="Create API Key dialog showing the key name and scope selection" width="1223" height="785" data-path="images/api-keys/api-key-create-en.png" />
</Frame>

### Understand scope selection

| Scope option                | Result                                                           |
| --------------------------- | ---------------------------------------------------------------- |
| **Select all**              | Includes the complete division structure of the selected company |
| **Selection only (leaves)** | Includes only the explicitly selected leaf divisions             |
| **Include sub-divisions**   | Includes a selected division and its subordinate divisions       |

```mermaid theme={"theme":{"light":"github-light","dark":"github-dark"}}
flowchart TD
    C[Selected company] --> S[Sales]
    C --> O[Operations]
    S --> E[Enterprise]
    S --> M[SMB]

    ALL[Select all] -.-> C
    SUB[Include sub-divisions: Sales] -.-> S
    LEAF[Selection only: Enterprise] -.-> E
```

In the illustrated example, **Select all** applies the key to the complete company structure of the selected organization.

<Warning>
  Use the narrowest scope required. Create separate keys for systems with different responsibilities, companies, or operational owners.
</Warning>

Click **Add** to apply the selected scope and then **Save** to create the key.

## Copy and store the generated key

JobHandy displays the complete credential immediately after creation. The key is active and can be used in the `X-API-Key` request header.

<Frame>
  <img src="https://mintcdn.com/jobhandy/eYWivtukLSxRL1Cd/images/api-keys/api-key-created-en.png?fit=max&auto=format&n=eYWivtukLSxRL1Cd&q=85&s=322caad7e8ab8a0b6882dc0fb60f6f59" alt="Confirmation after creating a JobHandy API key" width="1224" height="782" data-path="images/api-keys/api-key-created-en.png" />
</Frame>

<Warning>
  Copy the key immediately and store it in a secret manager. Do not place API keys in source code, browser applications, public repositories, tickets, screenshots, or application logs.
</Warning>

## Verify the active key

After closing the dialog, the key appears with status **ACTIVE**. The **Deactivate** action revokes the credential without deleting it.

<Frame>
  <img src="https://mintcdn.com/jobhandy/eYWivtukLSxRL1Cd/images/api-keys/api-key-active-en.png?fit=max&auto=format&n=eYWivtukLSxRL1Cd&q=85&s=ad42c46bb01c28e4af77bdd136475d4b" alt="Newly created JobHandy API key with ACTIVE status and the Deactivate action" width="1222" height="787" data-path="images/api-keys/api-key-active-en.png" />
</Frame>

## Deactivate, reactivate, or delete

Click **Deactivate** when access must be revoked. Deactivation takes effect for subsequent protected requests. After deactivation, the key is shown with status **INACTIVE** and can be reactivated or deleted.

<Frame>
  <img src="https://mintcdn.com/jobhandy/eYWivtukLSxRL1Cd/images/api-keys/api-key-inactive-en.png?fit=max&auto=format&n=eYWivtukLSxRL1Cd&q=85&s=d2fa39506ffdd49b8a8dec81b4d97798" alt="Inactive JobHandy API key showing Reactivate and Delete actions" width="1224" height="784" data-path="images/api-keys/api-key-inactive-en.png" />
</Frame>

| Action         | Use when                                           | Result                                                 |
| -------------- | -------------------------------------------------- | ------------------------------------------------------ |
| **Deactivate** | Access must stop immediately but might be restored | The key no longer authenticates protected requests     |
| **Reactivate** | The same credential should become usable again     | The inactive key becomes active again                  |
| **Delete**     | The credential is permanently retired              | The key can no longer be restored through reactivation |

## Rotate a key without downtime

```mermaid theme={"theme":{"light":"github-light","dark":"github-dark"}}
sequenceDiagram
    participant Admin as Company administrator
    participant Portal as JobHandy administration
    participant Secrets as Secret manager
    participant Client as Integration
    participant API as JobHandy API

    Admin->>Portal: Create replacement key with equivalent scope
    Portal-->>Admin: Display replacement key
    Admin->>Secrets: Store replacement key
    Secrets-->>Client: Deploy new credential
    Client->>API: Verify protected request
    API-->>Client: Success + X-Request-ID
    Admin->>Portal: Deactivate old key
    Admin->>Portal: Delete old key after verification
```

Do not deactivate the old key until the replacement has completed a successful protected request in every active integration instance.

<Card title="Detailed rotation procedure" icon="rotate-cw" horizontal href="/guides/rotate-api-keys">
  Use the operational runbook for preparation, rollout, verification, rollback, and retirement.
</Card>

## API key lifecycle

```mermaid theme={"theme":{"light":"github-light","dark":"github-dark"}}
stateDiagram-v2
    [*] --> ACTIVE: Create
    ACTIVE --> INACTIVE: Deactivate
    INACTIVE --> ACTIVE: Reactivate
    INACTIVE --> DELETED: Delete
    DELETED --> [*]
```

For request headers and authentication failures, continue with [Authentication](/get-started/authentication).
