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

# API-sleutel aanmaken

> Met dit endpoint voer je de volgende bewerking uit: API-sleutel aanmaken.



## OpenAPI

````yaml nl/api-reference/openapi.yaml post /api/v1/users/{user_id}/keys
openapi: 3.1.0
info:
  title: Anlytic API
  version: '1.0'
  description: >-
    De Anlytic REST API. Alle endpoints zijn beschikbaar onder `/api/v1/`.


    ## Authenticatie


    Voor de meeste endpoints is een **Bearer JWT** nodig die je via de
    authenticatiestroom verkrijgt:

    1. `GET /api/v1/users/otp` — vraag een eenmalige toegangscode aan met HTTP
    Basic Auth.

    2. `GET /api/v1/users/token/{kid}` — wissel de code in voor een
    werkruimte-JWT.


    Stuur de JWT bij elke volgende aanvraag mee als `Authorization: Bearer
    <token>`.


    Je kunt ook een **API-sleutel** via dezelfde header gebruiken:
    `Authorization: API-Key <key>`.
  contact:
    name: Anlytic Support
    url: https://anlytic.com
servers:
  - url: https://app.anlytic.com
    description: Productie
security:
  - bearerAuth: []
  - apiKeyAuth: []
tags:
  - name: Configuratie
    description: API-configuratie en beleid
  - name: Triggers
    description: Geplande grafiektriggers en triggeracties
paths:
  /api/v1/users/{user_id}/keys:
    post:
      tags:
        - API-sleutels
      summary: API-sleutel aanmaken
      description: >-
        Met dit endpoint voer je de volgende bewerking uit: API-sleutel
        aanmaken.
      operationId: createApiKey
      parameters:
        - name: user_id
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/UUID'
          description: Waarde voor `user_id`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NewAPIKey'
      responses:
        '201':
          description: Resource aangemaakt
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NewAPIKeyResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
components:
  schemas:
    UUID:
      type: string
      format: uuid
      example: 550e8400-e29b-41d4-a716-446655440000
    NewAPIKey:
      type: object
      required:
        - name
        - scopes
      properties:
        name:
          type: string
        scopes:
          type: array
          items:
            type: string
            enum:
              - admin
              - workspace_admin
              - api
              - api_read
              - auth
              - auth_read
          description: Minimaal één bereik is verplicht
        expired_at:
          type:
            - string
            - 'null'
          description: Vervaldatum in de notatie `dd-MM-yyyy` (bijvoorbeeld "31-12-2024")
          example: 31-12-2024
    NewAPIKeyResponse:
      type: object
      properties:
        id:
          $ref: '#/components/schemas/UUID'
        key:
          type: string
          description: Onbewerkte API-sleutel — wordt één keer getoond; bewaar deze veilig
    Error:
      type: object
      properties:
        error:
          type: string
          description: Voor mensen leesbare foutmelding
        code:
          type: string
          description: Machineleesbare foutcode
  responses:
    Unauthorized:
      description: Authenticatietoken ontbreekt of is ongeldig
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: Onvoldoende rechten
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Stuur een geldig token mee via de header `Authorization: Bearer
        <token>`.
    apiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: Voer `API-Key <key>` in.

````