---
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`

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

- `400` — Error response when project is archived.

## Changes

- **2026-09-08** `3e1e81935a39` — 2 info
  - added the new optional request property `expires_in_seconds`
  - added the optional property `api_key/anyOf[#/components/schemas/ProjectServiceAccountApiKey]/expires_at` to the response with the `200` status
- **2026-09-03** `9430b00d75b4` — 1 info
  - added the optional property `error/misalignment` to the response with the `400` status
- **2026-08-05** `ab0c5306e390` — 1 warning, 1 info
  - added the new `none` enum value to the `role` response property for the response status `200`
  - added the new optional request property `create_service_account_only`
- **2026-05-13** `74cbcf73838f` — 8 breaking, 2 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
  - …6 more
- **2024-08-06** `8eca3b09b705` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/openai/apis/openapi/changes/organization/projects/:project_id/service_accounts/post.md)

---

[API](https://skmtc.dev/openai/apis/openapi.md) · [All operations](https://skmtc.dev/openai/apis/openapi/llms.txt) · [OpenAPI document](https://skmtc.dev/openai/apis/openapi/revisions/26bd6202a0ad?raw)
