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

# Create API key for service user

> Create a new API key for a service user.

The caller must have ManageAccountServiceUsers permission. Returns 409
while static service user keys are disabled for the enterprise, unless the
service user backs SCIM or an active Outpost.

## Permissions

Requires a [service user](/api-reference/v3/service-users/members-service-users) or [personal access token](/api-reference/personal-access-tokens) with the `ManageAccountServiceUsers` permission at the enterprise level.


## OpenAPI

````yaml v3-openapi.yaml POST /v3beta1/enterprise/service-users/{service_user_id}/api-keys
openapi: 3.1.0
info:
  description: Devin v3 API with Service User authentication and RBAC
  title: Devin API v3
  version: 3.0.0
servers: []
security:
  - bearerAuth: []
paths:
  /v3beta1/enterprise/service-users/{service_user_id}/api-keys:
    post:
      tags:
        - service_user_api_keys
      summary: Create API key for service user
      description: >-
        Create a new API key for a service user.


        The caller must have ManageAccountServiceUsers permission. Returns 409

        while static service user keys are disabled for the enterprise, unless
        the

        service user backs SCIM or an active Outpost.
      operationId: >-
        handle_create_service_user_api_key_v3beta1_enterprise_service_users__service_user_id__api_keys_post
      parameters:
        - description: 'Service user ID (prefix: service-user-)'
          in: path
          name: service_user_id
          required: true
          schema:
            example: service-user-abc123def456
            title: Service User Id
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateApiKeyRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiKeyWithTokenResponse'
          description: Successful Response
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: Forbidden
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: Not Found
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: Conflict
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: Unprocessable Content
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetail'
          description: Too Many Requests
components:
  schemas:
    CreateApiKeyRequest:
      properties:
        expires_at:
          anyOf:
            - type: integer
            - type: 'null'
          description: >-
            Optional expiration as a UNIX timestamp in seconds. Must be in the
            future if provided.
          title: Expires At
        name:
          maxLength: 256
          minLength: 1
          title: Name
          type: string
      required:
        - name
      title: CreateApiKeyRequest
      type: object
    ApiKeyWithTokenResponse:
      description: >-
        Shared response model for API key creation/rotation (includes one-time
        token).
      properties:
        api_key_id:
          title: Api Key Id
          type: string
        api_key_name:
          title: Api Key Name
          type: string
        token:
          description: >-
            The raw API token. This is only shown once at creation/rotation
            time.
          title: Token
          type: string
      required:
        - api_key_id
        - api_key_name
        - token
      title: ApiKeyWithTokenResponse
      type: object
    ProblemDetail:
      description: >-
        RFC 9457 application/problem+json error body for the v3 API.


        detail is retained from the legacy {"detail": ...} body for back-compat;
        the

        other members are additive. errors carries field-level validation
        failures

        (422 only).
      properties:
        detail:
          anyOf:
            - type: string
            - type: 'null'
          description: A human-readable explanation specific to this occurrence.
          title: Detail
        error_code:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            Machine-readable code for blocked-action refusals (e.g.
            "user_frozen", "migrated_session").
          title: Error Code
        errors:
          anyOf:
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
          description: Field-level validation errors (422 responses only).
          title: Errors
        instance:
          anyOf:
            - type: string
            - type: 'null'
          description: A URI reference (the request path) for this occurrence.
          title: Instance
        status:
          description: The HTTP status code.
          title: Status
          type: integer
        title:
          description: A short, human-readable summary of the problem type.
          title: Title
          type: string
        type:
          default: about:blank
          description: A URI reference identifying the problem type.
          title: Type
          type: string
      required:
        - title
        - status
      title: ProblemDetail
      type: object
  securitySchemes:
    bearerAuth:
      description: 'Service User credential (prefix: cog_)'
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.