---
title: "Create Service Account"
method: POST
path: "/organizations/{organizationId}/service-accounts"
tags: ["Create Service Accounts"]
---

# Create Service Account

`POST /organizations/{organizationId}/service-accounts`

Create a new service account for your organization and optionally add it to one or more projects in your organization

## Request body

- CreateServiceAccountRequest
  - `username` string, required — A descriptive name for the service account
  - `role` 'owner' | 'admin' | 'analyst' | 'consumer' — The service account's role
  - `expires` string, date-time — The datetime that the service account should expire
  - `projects` object[] — A list of projects to make this serivce account a member of
    - `id` integer — The project id to add the service account to
    - `role` 'owner' | 'admin' | 'analyst' | 'consumer' — The service account's role

## Response `201`

Service account successfully created

- CreateServiceAccountResponse
  - `results` object
    - `token` string — The secret key for this service account. Note: This cannot be recovered so you should immediately store this somewhere secure.
    - `id` integer — The unique identifier for this service account
    - `username` string — The username of the service account
    - `last_used` string, date-time — The date/time this service account was last used for authentication
    - `expires` string, date-time — The date/time this service account will expire
    - `creator` integer — The Mixpanel user id that created this service account
    - `created` string, date-time — The date/time this service account was created
    - `user` integer — The Mixpanel user id that this serivce account represents. This is only used internally and is safe to ignore.
  - `status` 'ok' — "ok" if the request succeeded, "error" otherwise.

## Other responses

- `400` — Bad request
- `401` — Unauthorized
- `403` — Forbidden
- `404` — Not Found

---

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