---
title: "Create a service account."
method: POST
path: "/api/admin/service-account"
tags: ["Service Accounts"]
---

# Create a service account.

`POST /api/admin/service-account`

**Enterprise feature**

Creates a new service account.

## Request body

- CreateServiceAccountSchema — Describes the properties required to create a new service account
  - `username` string, required — The username of the service account
  - `name` string, required — The name of the service account
  - `rootRole` integer, required — The id of the root role for the service account

## Response `201`

The resource was successfully created.

- ServiceAccountSchema — Represents a [service account](https://docs.getunleash.io/concepts/service-accounts). Service accounts are used to let systems interact with the Unleash API.
  - `id` number, required — The service account id
  - `isAPI` boolean — Deprecated: for internal use only, should not be exposed through the API
  - `name` string — The name of the service account
  - `email` string — Deprecated: service accounts don't have emails associated with them
  - `username` string — The service account username
  - `imageUrl` string — The service account image url
  - `inviteLink` string — Deprecated: service accounts cannot be invited via an invitation link
  - `loginAttempts` number — Deprecated: service accounts cannot log in to Unleash
  - `emailSent` boolean — Deprecated: internal use only
  - `rootRole` integer — The root role id associated with the service account
  - `seenAt` string, date-time, nullable — Deprecated. This property is always `null`. To find out when a service account was last seen, check its `tokens` list and refer to each token's `lastSeen` property instead.
  - `createdAt` string, date-time — The service account creation date
  - `tokens` PatSchema[] — The list of tokens associated with the service account
    - `id` integer, required — The PAT's ID. PAT IDs are incrementing integers. In other words, a more recently created PAT will always have a higher ID than an older one.
    - `secret` string — The token used for authentication. It is automatically generated by Unleash when the PAT is created and that is the only time this property is returned.
    - `createdAt` string, date-time, required — The date and time of when the PAT was created.
    - `seenAt` string, date-time, nullable — When the PAT was last seen/used to authenticate with. `null` if it has not been used yet.
    - `userId` integer — The ID of the user this PAT belongs to.
    - `description` string, required — The PAT's description.
    - `expiresAt` string, date-time, required — The PAT's expiration date.

## Other responses

- `400` — The request data does not match what we expect.
- `401` — Authorization information is missing or invalid. Provide a valid API token as the `authorization` header, e.g. `authorization:*.*.my-admin-token`.
- `403` — The provided user credentials are valid, but the user does not have the necessary permissions to perform this operation
- `409` — The provided resource can not be created or updated because it would conflict with the current state of the resource or with an already existing resource, respectively.
- `415` — The operation does not support request payloads of the provided type. Please ensure that you're using one of the listed payload types and that you have specified the right content type in the "content-type" header.

---

[API](https://skmtc.net/unleash/apis/unleash-api-3.md) · [All operations](https://skmtc.net/unleash/apis/unleash-api-3/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/unleash/unleash-api-3/revisions/b2c3116e633e/schema)
