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

# Create application API keys for users

> Create application API keys scoped to specific users. Each key can only perform operations on behalf of the user it was created for.



## OpenAPI

````yaml https://admin.trophy.so/v1/openapi post /application-api-keys
openapi: 3.1.0
info:
  title: Trophy
  version: 1.19.0
servers:
  - x-fern-server-name: Admin API
    url: https://admin.trophy.so/v1
    description: Admin API
security: []
paths:
  /application-api-keys:
    servers:
      - url: https://admin.trophy.so/v1
        description: Admin API
    post:
      tags:
        - Admin
      summary: Create application API keys for users
      description: >-
        Create application API keys scoped to specific users. Each key can only
        perform operations on behalf of the user it was created for.
      operationId: admin_application_api_keys_create
      requestBody:
        description: >-
          Array of users to create application API keys for. Maximum 100 users
          per request.
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateApplicationKeysRequest'
            examples:
              Create application keys:
                value:
                  - userId: user_123
                  - userId: user_456
      responses:
        '200':
          description: Successful operation (no keys created)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateApplicationKeysResponse'
        '201':
          description: Created (at least one application API key created)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateApplicationKeysResponse'
              examples:
                Success:
                  value:
                    created:
                      - id: 550e8400-e29b-41d4-a716-446655440000
                        userId: user_123
                        key: app_XXXXX.YOUR_API_KEY
                        prefix: app_XXXXX
                    issues: []
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AdminErrorBody'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AdminErrorBody'
        '422':
          description: Unprocessible Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AdminErrorBody'
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: javascript
          source: |
            import { TrophyApiClient } from '@trophyso/node';

            const trophy = new TrophyApiClient({
              apiKey: 'YOUR_API_KEY'
            });

            const response = await trophy.admin.applicationApiKeys.create([
              { userId: 'user_123' }
            ]);
        - lang: python
          source: |
            from trophy import TrophyApi

            client = TrophyApi(api_key='YOUR_API_KEY')

            response = client.admin.applicationApiKeys.create([
              { "userId": "user_123" }
            ])
        - lang: go
          source: >
            import (
              "context"

              api "github.com/trophyso/trophy-go"
              trophyclient "github.com/trophyso/trophy-go/client"
              "github.com/trophyso/trophy-go/option"
            )


            client := trophyclient.NewClient(
              option.WithApiKey("YOUR_API_KEY"),
            )


            response, err :=
            client.Admin.ApplicationApiKeys.Create(context.TODO(),
            api.CreateApplicationKeysRequest{})
components:
  schemas:
    CreateApplicationKeysRequest:
      title: CreateApplicationKeysRequest
      type: array
      description: Request body for creating application API keys.
      items:
        $ref: '#/components/schemas/CreateApplicationKeyRequestItem'
      minItems: 1
      maxItems: 100
    CreateApplicationKeysResponse:
      title: CreateApplicationKeysResponse
      type: object
      description: Response containing created application API keys and any issues.
      properties:
        created:
          type: array
          items:
            $ref: '#/components/schemas/CreatedApplicationKey'
          description: Array of successfully created application API keys.
        issues:
          type: array
          items:
            $ref: '#/components/schemas/AdminIssue'
          description: Array of issues encountered during creation.
      required:
        - created
        - issues
    AdminErrorBody:
      title: AdminErrorBody
      type: object
      properties:
        error:
          type: string
      required:
        - error
    CreateApplicationKeyRequestItem:
      title: CreateApplicationKeyRequestItem
      type: object
      description: A user to create an application API key for.
      properties:
        userId:
          type: string
          description: The user ID to scope the application API key to.
          example: user_123
          maxLength: 255
      required:
        - userId
    CreatedApplicationKey:
      title: CreatedApplicationKey
      type: object
      description: A newly created application API key.
      properties:
        id:
          type: string
          format: uuid
          description: The unique identifier of the API key. Use this ID to delete the key.
          example: 550e8400-e29b-41d4-a716-446655440000
        userId:
          type: string
          description: The user ID the key is scoped to.
          example: user_123
        key:
          type: string
          description: >-
            The full API key value. This is only returned once at creation time
            and cannot be retrieved again.
          example: app_XXXXX.YOUR_API_KEY
        prefix:
          type: string
          description: The key prefix used for cache lookup.
          example: app_XXXXX
      required:
        - id
        - userId
        - key
        - prefix
    AdminIssue:
      title: AdminIssue
      type: object
      description: An issue encountered while processing an item in an admin API request.
      properties:
        id:
          type: string
          description: The ID of the resource the issue relates to, when applicable.
          example: 550e8400-e29b-41d4-a716-446655440000
        userId:
          type: string
          description: The ID of the user the issue relates to, when applicable.
          example: user-123
        boostId:
          type: string
          description: The ID of the points boost the issue relates to, when applicable.
          example: 550e8400-e29b-41d4-a716-446655440000
        index:
          type: integer
          description: >-
            The zero-based index of the item the issue relates to, when no
            resource ID exists yet.
          example: 0
        severity:
          type: string
          enum:
            - error
            - warning
          description: The severity level of the issue.
          example: warning
        message:
          type: string
          description: A human-readable description of the issue.
          example: Would exceed maximum freeze limit
      required:
        - severity
        - message
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

````