--- title: "Create a service account" canonical: "https://admiral.io/docs/api/serviceaccounts/ServiceAccountAPI_CreateServiceAccount" --- # Create a service account `POST https://api.admiral.io/v1/serviceAccounts` - ALREADY_EXISTS when another service account has that name, or trusts the same issuer and subject. Scope: `serviceaccount:write` ### Query parameters - `request_id` (string (uuid)): (OPTIONAL) A UUID the client generates once per create and sends again on every retry. A repeat within 24 hours returns the first result and creates nothing. The same id with a different request is refused with INVALID_ARGUMENT. Without one, every call creates. request_id.not_zero // request_id may not be the zero UUID ### Request body - `uid` (string): `sa-` and twelve base36 characters. Never changes and is never reused, so it is what a reference to the service account holds, and the `sub` of every token it signs in with. Pattern `^sa-[0-9a-z]+$`. Read-only. - `name` (string, required): (IMMUTABLE) The name, such as `ci-deployer`. Unique among the organization's service accounts, set on create and changed only by RenameServiceAccount. An agent's takes the agent's name when it is made. Lowercase letters, digits and hyphens, starting with a letter and ending with a letter or digit, 1 to 63 characters. It may not have the shape of a uid (`sa-` and twelve characters). name.not_uid // a service account name may not have the shape of a uid Pattern `^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`. Length 1 to 63. - `display_name` (string): A label for people, such as "CI deployer". Optional; clients show the name when it is unset. Length at most 128. - `resource_name` (string): (IDENTIFIER) The resource name, `serviceAccounts/{service_account}`, such as `serviceAccounts/ci-deployer`. Built from the service account's name, so it changes when the service account is renamed; refer to it by `uid` to keep a reference stable. Pattern `^serviceAccounts/[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`. - `subject` (string): (IMMUTABLE) The `sub` a token must carry. For a Kubernetes service account, `system:serviceaccount::`; for GitHub Actions, `repo:/:ref:refs/heads/` or `repo:/:environment:`. For an agent's, recorded from its verified token when it enrolls; empty before. Fixed once set. Length at most 512. - `issuer_id` (string): (IMMUTABLE) `iss-`: the issuer whose tokens it accepts. For an agent's, set when the agent enrolls; empty before. For one that runs no agent, set on create. Pattern `^iss-[0-9a-z]+$`. - `agent_id` (string): `agt-`: the agent that runs as this service account. Empty for one that runs no agent. Read-only. - `enrolled_at` (Timestamp): A point in time in RFC 3339 format, with up to nanosecond precision. Output uses UTC (`Z`); input may use an offset from UTC. Read-only. - `etag` (string): Changes whenever the service account does. Send it back on rename or delete to refuse the change if someone else changed it first. Read-only. - `created_by` (ActorRef): ActorRef is a lightweight reference to the user or agent that performed an action. Server-populated on all resource responses. Clients should never send this. Read-only. - `id` (string): The actor's typed id: a `usr-` user id or an `sa-` service account id. - `display_name` (string): Human-readable name (e.g., "John Smith", "deploy-bot"). - `email` (string): Email address (empty for non-human actors). - `created_at` (Timestamp): A point in time in RFC 3339 format, with up to nanosecond precision. Output uses UTC (`Z`); input may use an offset from UTC. Read-only. ### Response 200 Success - `service_account` (ServiceAccount): ServiceAccount is a non-human principal. With `issuer_id` and `subject` set it signs in with a token from that issuer carrying that subject, matched exactly; the exact match is what secures a shared issuer, which anyone can get a token from. - `uid` (string): `sa-` and twelve base36 characters. Never changes and is never reused, so it is what a reference to the service account holds, and the `sub` of every token it signs in with. Pattern `^sa-[0-9a-z]+$`. Read-only. - `name` (string, required): (IMMUTABLE) The name, such as `ci-deployer`. Unique among the organization's service accounts, set on create and changed only by RenameServiceAccount. An agent's takes the agent's name when it is made. Lowercase letters, digits and hyphens, starting with a letter and ending with a letter or digit, 1 to 63 characters. It may not have the shape of a uid (`sa-` and twelve characters). name.not_uid // a service account name may not have the shape of a uid Pattern `^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`. Length 1 to 63. - `display_name` (string): A label for people, such as "CI deployer". Optional; clients show the name when it is unset. Length at most 128. - `resource_name` (string): (IDENTIFIER) The resource name, `serviceAccounts/{service_account}`, such as `serviceAccounts/ci-deployer`. Built from the service account's name, so it changes when the service account is renamed; refer to it by `uid` to keep a reference stable. Pattern `^serviceAccounts/[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`. - `subject` (string): (IMMUTABLE) The `sub` a token must carry. For a Kubernetes service account, `system:serviceaccount::`; for GitHub Actions, `repo:/:ref:refs/heads/` or `repo:/:environment:`. For an agent's, recorded from its verified token when it enrolls; empty before. Fixed once set. Length at most 512. - `issuer_id` (string): (IMMUTABLE) `iss-`: the issuer whose tokens it accepts. For an agent's, set when the agent enrolls; empty before. For one that runs no agent, set on create. Pattern `^iss-[0-9a-z]+$`. - `agent_id` (string): `agt-`: the agent that runs as this service account. Empty for one that runs no agent. Read-only. - `enrolled_at` (Timestamp): A point in time in RFC 3339 format, with up to nanosecond precision. Output uses UTC (`Z`); input may use an offset from UTC. Read-only. - `etag` (string): Changes whenever the service account does. Send it back on rename or delete to refuse the change if someone else changed it first. Read-only. - `created_by` (ActorRef): ActorRef is a lightweight reference to the user or agent that performed an action. Server-populated on all resource responses. Clients should never send this. Read-only. - `id` (string): The actor's typed id: a `usr-` user id or an `sa-` service account id. - `display_name` (string): Human-readable name (e.g., "John Smith", "deploy-bot"). - `email` (string): Email address (empty for non-human actors). - `created_at` (Timestamp): A point in time in RFC 3339 format, with up to nanosecond precision. Output uses UTC (`Z`); input may use an offset from UTC. Read-only.