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

# Create an environment API key

> Create a new environment API key

<Info>
  Requires an [Account API key](/docs/reference/backend/http-api/api-keys#account-api-keys). Create one from [Account API keys](https://app.nango.dev/api-keys) in the dashboard.
</Info>

Creates an Environment API key. Keys created by this endpoint always have full environment access (`environment:*`). This endpoint does not accept custom scopes. Create keys with custom scopes under **Environment Settings > API Keys**.

`environment_id` is the numeric ID returned when the environment was [created](/docs/reference/backend/http-api/environments/create).

<ResponseExample>
  ```json Example Response theme={null}
  {
    "data": {
      "id": 456,
      "display_name": "provisioned-ci",
      "scopes": ["environment:*"],
      "secret": "<YOUR-ENVIRONMENT-API-KEY>",
      "created_at": "2026-08-18T12:00:00.000Z"
    }
  }
  ```
</ResponseExample>


## OpenAPI

````yaml POST /environment/api-keys
openapi: 3.1.0
info:
  title: Nango API
  description: Nango API specs used to authorize & sync data with external APIs.
  version: 1.0.0
servers:
  - url: https://api.nango.dev
    description: Production server
  - url: http://localhost:3003
    description: Local server
security:
  - bearerAuth: []
externalDocs:
  url: https://nango.dev/docs/reference/backend/http-api/authentication
paths:
  /environment/api-keys:
    post:
      summary: Create an environment API key
      description: Create a new environment API key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
                - environment_id
                - display_name
              properties:
                environment_id:
                  type: integer
                  minimum: 1
                  description: >-
                    Numeric environment ID returned when the environment was
                    created.
                  example: 123
                display_name:
                  type: string
                  description: >-
                    Display name for the key. Must be unique within the
                    environment.
                  minLength: 1
                  maxLength: 255
                  example: provisioned-ci
      responses:
        '200':
          description: Successfully created an Environment API key
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: object
                    required:
                      - id
                      - display_name
                      - scopes
                      - secret
                      - created_at
                    properties:
                      id:
                        type: integer
                        description: Numeric key ID. Use this to delete the key later.
                        example: 456
                      display_name:
                        type: string
                        example: provisioned-ci
                      scopes:
                        type: array
                        items:
                          type: string
                        description: >-
                          Always `environment:*` for keys created by this
                          endpoint.
                        example:
                          - environment:*
                      secret:
                        type: string
                        description: >-
                          The API key secret. Store it now; it is not returned
                          again.
                      created_at:
                        type: string
                        format: date-time
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: A key with this display name already exists in the environment.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StdError'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  responses:
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/StdError'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/StdError'
    Forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/StdError'
    NotFound:
      description: Not Found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/StdError'
    ServerError:
      description: Server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/StdError'
  schemas:
    StdError:
      type: object
      additionalProperties: false
      properties:
        error:
          type: object
          additionalProperties: false
          required:
            - code
          properties:
            code:
              type: string
            message:
              type: string
            errors:
              type: array
              items:
                type: object
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        An Environment API key from your Nango environment, or an Account API
        key for account-level endpoints.

````