---
title: "Creates a new service account in the project. This also returns an unredacted API key for the service account."
url: "https://kongair.terwilligar.com/apis/openai-api-2-3-0/versions/ea92d048-c746-4ead-a6a8-da28d93137d1/operations/create-project-service-account"
---

> Full API specification: https://kongair.terwilligar.com/apis/openai-api-2-3-0/versions/ea92d048-c746-4ead-a6a8-da28d93137d1.md

# Creates a new service account in the project. This also returns an unredacted API key for the service account.

`POST` `/organization/projects/{project_id}/service_accounts`

Operation ID: `create-project-service-account`

## Path parameters

- `project_id` (string, required) - The ID of the project.

## Request body (required)

Content types: `application/json`

## Responses

- `200` - Project service account created successfully.
- `400` - Error response when project is archived.

## OpenAPI definition

```yaml
openapi: 3.0.0
info:
  title: OpenAI API
  version: 2.3.0
servers:
  - url: https://api.openai.com/v1
paths:
  /organization/projects/{project_id}/service_accounts:
    post:
      summary: Creates a new service account in the project. This also returns an
        unredacted API key for the service account.
      operationId: create-project-service-account
      tags:
        - Projects
      parameters:
        - name: project_id
          in: path
          description: The ID of the project.
          required: true
          schema:
            type: string
      requestBody:
        description: The project service account create request payload.
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ProjectServiceAccountCreateRequest"
      responses:
        "200":
          description: Project service account created successfully.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProjectServiceAccountCreateResponse"
        "400":
          description: Error response when project is archived.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
      x-oaiMeta:
        name: Create project service account
        group: administration
        returns: The created
          [ProjectServiceAccount](/docs/api-reference/project-service-accounts/object)
          object.
        examples:
          request:
            curl: |
              curl -X POST https://api.openai.com/v1/organization/projects/proj_abc/service_accounts \
                -H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
                -H "Content-Type: application/json" \
                -d '{
                    "name": "Production App"
                }'
          response: |
            {
                "object": "organization.project.service_account",
                "id": "svc_acct_abc",
                "name": "Production App",
                "role": "member",
                "created_at": 1711471533,
                "api_key": {
                    "object": "organization.project.service_account.api_key",
                    "value": "sk-abcdefghijklmnop123",
                    "name": "Secret Key",
                    "created_at": 1711471533,
                    "id": "key_abc"
                }
            }
security:
  - ApiKeyAuth: []
components:
  schemas:
    ProjectServiceAccountCreateRequest:
      type: object
      properties:
        name:
          type: string
          description: The name of the service account being created.
      required:
        - name
    ProjectServiceAccountCreateResponse:
      type: object
      properties:
        object:
          type: string
          enum:
            - organization.project.service_account
          x-stainless-const: true
        id:
          type: string
        name:
          type: string
        role:
          type: string
          enum:
            - member
          description: Service accounts can only have one role of type `member`
          x-stainless-const: true
        created_at:
          type: integer
        api_key:
          $ref: "#/components/schemas/ProjectServiceAccountApiKey"
      required:
        - object
        - id
        - name
        - role
        - created_at
        - api_key
    ErrorResponse:
      type: object
      properties:
        error:
          $ref: "#/components/schemas/Error"
      required:
        - error
    ProjectServiceAccountApiKey:
      type: object
      properties:
        object:
          type: string
          enum:
            - organization.project.service_account.api_key
          description: The object type, which is always
            `organization.project.service_account.api_key`
          x-stainless-const: true
        value:
          type: string
        name:
          type: string
        created_at:
          type: integer
        id:
          type: string
      required:
        - object
        - value
        - name
        - created_at
        - id
    Error:
      type: object
      properties:
        code:
          type: string
          nullable: true
        message:
          type: string
          nullable: false
        param:
          type: string
          nullable: true
        type:
          type: string
          nullable: false
      required:
        - type
        - message
        - param
        - code
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
```
