---
title: "Create project service account"
method: POST
path: "/organization/projects/{project_id}/service_accounts"
tags: ["Projects"]
---

# Create project service account

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

## Request

- Base URL: `https://api.openai.com/v1`
- URL: `https://api.openai.com/v1/organization/projects/{project_id}/service_accounts`
- Auth: HTTP bearer

Creates a new service account in the project. By default, this also returns an unredacted API key for the service account.

## Path parameters

- `project_id` string, required

## Request body

- ProjectServiceAccountCreateRequest
  - `name` string, required: The name of the service account being created.
  - `create_service_account_only` boolean, nullable: Create the service account without default roles or an API key.
  - `expires_in_seconds` integer, nullable: Number of seconds until the initial API key expires. If omitted or null, the key does not expire unless the effective organization or project policy requires an expiration. When a policy sets a maximum lifetime, this value must be provided and must not exceed that limit. A non-null value cannot be used when `create_service_account_only` is true.

## Response `200`

Project service account created successfully.

- ProjectServiceAccountCreateResponse
  - `object` 'organization.project.service_account', required
  - `id` string, required
  - `name` string, required
  - `role` 'member' | 'none', required: Service accounts created with default project membership have role `member`. Accounts created with `create_service_account_only` have role `none`.
  - `created_at` integer, required
  - `api_key` ProjectServiceAccountApiKey, required
    - `object` 'organization.project.service_account.api_key', required: The object type, which is always `organization.project.service_account.api_key`
    - `value` string, required
    - `name` string, required
    - `created_at` integer, required
    - `expires_at` integer, nullable: The Unix timestamp (in seconds) when the API key expires, or null if it does not expire.
    - `id` string, required

## Other responses

- `201`: Project service account created successfully.
- `400`: Error response when project is archived.
- `403`: The caller does not have permission to perform this operation.
- `404`: A requested project, user, service account, or API key was not found.
- `429`: Too many management requests. Reduce the request rate and try again later.

## Changes

- **2026-10-06** `487892d3954e`: 4 info
  - added the optional property `error/anyOf[#/components/schemas/Error]/misalignment/review_target` to the response with the `403` status
  - added the optional property `error/misalignment/review_target` to the response with the `400` status
  - added the optional property `error/misalignment/review_target` to the response with the `404` status
  - added the optional property `error/misalignment/review_target` to the response with the `429` status
- **2026-10-05** `7f654af7f94f`: 8 breaking, 1 warning, 9 info
  - response property `error/code` list-of-types was widened by adding types `null` to media type `application/json` of response `400`
  - response property `error/param` list-of-types was widened by adding types `null` to media type `application/json` of response `400`
  - the `api_key` response's property type changed from `object` to no type for status `200`
  - removed the required property `api_key/created_at` from the response with the `200` status
  - …14 more

[Operation history](https://skmtc.dev/omnistack-sh/apis/openai-api/changes/organization/projects/:project_id/service_accounts/post.md)

---

[API](https://skmtc.dev/omnistack-sh/apis/openai-api.md) - [All operations](https://skmtc.dev/omnistack-sh/apis/openai-api/llms.txt) - [OpenAPI document](https://skmtc.dev/omnistack-sh/apis/openai-api/revisions/0a26f104d35f?raw)
