---
updatedAt: 2026-09-25T13:55:16.000Z
agentTools:
  projectIndex: https://developer.doit.com/llms.txt
---

# Create a service account

Creates a service account owned by the authenticated customer. It cannot authenticate anything until it has an API token; mint one with the `api-tokens` sub-resource. Returns `409` when another service account of the customer already uses `name`. With `dryRun=true` the request goes through the same checks as a real create (name bounds and uniqueness, permission names, caller scope) and returns the same errors without creating anything. When the caller authenticates with a service account token, `createdBy`, `createdByEmail` and `createdByUserId` are `null`. Requires the `serviceAccountCreator` permission.

# OpenAPI definition

```json
{
  "openapi": "3.0.1",
  "info": {
    "title": "DoiT Cloud Intelligence",
    "description": "Programmatic access to DoiT Platform",
    "version": "v1"
  },
  "servers": [
    {
      "url": "https://api.doit.com"
    }
  ],
  "security": [
    {
      "api_key": []
    },
    {
      "tenantId": [],
      "api_key": []
    }
  ],
  "tags": [
    {
      "name": "Service Accounts",
      "description": "Manage non-human identities whose API tokens call the DoiT API with a fixed set of permissions."
    }
  ],
  "paths": {
    "/iam/v1/service-accounts": {
      "post": {
        "tags": [
          "Service Accounts"
        ],
        "summary": "Create a service account",
        "description": "Creates a service account owned by the authenticated customer. It cannot authenticate anything until it has an API token; mint one with the `api-tokens` sub-resource. Returns `409` when another service account of the customer already uses `name`. With `dryRun=true` the request goes through the same checks as a real create (name bounds and uniqueness, permission names, caller scope) and returns the same errors without creating anything. When the caller authenticates with a service account token, `createdBy`, `createdByEmail` and `createdByUserId` are `null`. Requires the `serviceAccountCreator` permission.",
        "operationId": "createServiceAccount",
        "parameters": [
          {
            "$ref": "#/components/parameters/idempotencyKeyRequired"
          },
          {
            "$ref": "#/components/parameters/dryRun"
          }
        ],
        "requestBody": {
          "description": "The service account to create.",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateServiceAccountRequest"
              },
              "example": {
                "name": "terraform-ci",
                "description": "Manages DoiT resources from CI",
                "permissions": [
                  "cloudAnalyticsReadOnly",
                  "budgetsManager"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK - Dry run only (`dryRun=true`). Every check of a real create passed and nothing was created; `id`, `createTime`, `updateTime` and `etag` are `null`.",
            "headers": {
              "X-Dry-Run": {
                "$ref": "#/components/headers/XDryRun"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceAccount"
                },
                "example": {
                  "id": null,
                  "customerId": "Kp2mN8qL4vR0sT1wX3yZ",
                  "name": "terraform-ci",
                  "description": "Manages DoiT resources from CI",
                  "permissions": [
                    "cloudAnalyticsReadOnly",
                    "budgetsManager"
                  ],
                  "createdBy": null,
                  "createdByEmail": null,
                  "createdByUserId": null,
                  "createTime": null,
                  "updateTime": null,
                  "etag": null
                }
              }
            }
          },
          "201": {
            "description": "Created - Service account created.",
            "headers": {
              "Location": {
                "description": "URL of the created service account.",
                "schema": {
                  "type": "string"
                }
              },
              "ETag": {
                "$ref": "#/components/headers/ETag"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceAccount"
                },
                "example": {
                  "id": "Lq3nO9rM5wS2tU0xY4zA",
                  "customerId": "Kp2mN8qL4vR0sT1wX3yZ",
                  "name": "terraform-ci",
                  "description": "Manages DoiT resources from CI",
                  "permissions": [
                    "cloudAnalyticsReadOnly",
                    "budgetsManager"
                  ],
                  "createdBy": "Jane Doe",
                  "createdByEmail": "jane.doe@example.com",
                  "createdByUserId": "Ab1cD2eF3gH4iJ5kL6mN",
                  "createTime": "2026-09-01T08:00:00Z",
                  "updateTime": "2026-09-01T08:00:00Z",
                  "etag": "3f7a1c9e2b4d6f8a0c1e3a5b7d9f1b3d5f7a9c1e3b5d7f9a1c3e5b7d9f1a3c5e"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/401"
          },
          "403": {
            "$ref": "#/components/responses/403"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ServiceAccount": {
        "type": "object",
        "description": "A non-human identity owned by a customer. Its API tokens authenticate with exactly the permissions listed here.",
        "required": [
          "id",
          "customerId",
          "name",
          "description",
          "permissions",
          "createdBy",
          "createdByEmail",
          "createdByUserId",
          "createTime",
          "updateTime",
          "etag"
        ],
        "properties": {
          "id": {
            "type": "string",
            "nullable": true,
            "readOnly": true,
            "description": "Service account ID. `null` only on a dry-run create.",
            "example": "Lq3nO9rM5wS2tU0xY4zA"
          },
          "customerId": {
            "type": "string",
            "readOnly": true,
            "description": "ID of the customer that owns the service account.",
            "example": "Kp2mN8qL4vR0sT1wX3yZ"
          },
          "name": {
            "type": "string",
            "description": "Name, unique among the customer's service accounts."
          },
          "description": {
            "type": "string",
            "description": "Free-text description."
          },
          "permissions": {
            "type": "array",
            "description": "Platform permission names in camelCase, as shown in the DoiT console role editor.",
            "items": {
              "type": "string"
            }
          },
          "createdBy": {
            "type": "string",
            "nullable": true,
            "readOnly": true,
            "description": "Display name of the user who created the service account. `null` when unknown or when the service account was created with a service account token."
          },
          "createdByEmail": {
            "type": "string",
            "nullable": true,
            "readOnly": true,
            "description": "Email of the user who created the service account. `null` when unknown or when the service account was created with a service account token."
          },
          "createdByUserId": {
            "type": "string",
            "nullable": true,
            "readOnly": true,
            "description": "ID of the user who created the service account. `null` when unknown or when the service account was created with a service account token."
          },
          "createTime": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "readOnly": true,
            "description": "When the service account was created."
          },
          "updateTime": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "readOnly": true,
            "description": "When the service account was last changed."
          },
          "etag": {
            "type": "string",
            "nullable": true,
            "readOnly": true,
            "description": "Current version of the service account. Send it in `If-Match` to update or delete."
          }
        }
      },
      "CreateServiceAccountRequest": {
        "type": "object",
        "description": "Fields of a new service account.",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "description": "Name, unique among the customer's service accounts. Leading or trailing whitespace returns `400`.",
            "example": "terraform-ci"
          },
          "description": {
            "type": "string",
            "description": "Free-text description.",
            "example": "Manages DoiT resources from CI"
          },
          "permissions": {
            "type": "array",
            "description": "Platform permission names in camelCase, for example `cloudAnalyticsReadOnly`. An unknown name returns `422`.",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "description": "Standard error response structure.",
        "properties": {
          "error": {
            "type": "string",
            "description": "Detailed error message."
          }
        },
        "example": {
          "error": "The request could not be completed."
        }
      },
      "ProblemDetails": {
        "type": "object",
        "required": [
          "type",
          "title",
          "status",
          "detail",
          "instance",
          "code",
          "retryable"
        ],
        "additionalProperties": true,
        "description": "RFC 9457 Problem Details — standard DoiT error envelope for all non-2xx responses.",
        "properties": {
          "type": {
            "type": "string",
            "format": "uri",
            "example": "https://developer.doit.com/errors/not_found"
          },
          "title": {
            "type": "string",
            "example": "Resource not found"
          },
          "status": {
            "type": "integer",
            "example": 404
          },
          "detail": {
            "type": "string",
            "example": "customer not found"
          },
          "instance": {
            "type": "string",
            "format": "uri",
            "example": "https://api.doit.com/requests/req_01HX9P2KQVJ8Z3M4T5N6V7W8Y9"
          },
          "code": {
            "type": "string",
            "pattern": "^([a-z][a-z0-9_]*|[a-z][a-z0-9]*(?:-[a-z0-9]+)*\\.[a-z][a-z0-9_]*)$",
            "example": "not_found"
          },
          "retryable": {
            "type": "boolean",
            "example": false
          },
          "details": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "issue"
              ],
              "properties": {
                "issue": {
                  "type": "string",
                  "pattern": "^[a-z][a-z0-9_]*$"
                },
                "field": {
                  "type": "string"
                }
              },
              "additionalProperties": true
            }
          },
          "docsUrl": {
            "type": "string",
            "format": "uri",
            "nullable": true
          }
        }
      }
    },
    "responses": {
      "401": {
        "description": "Unauthorized - Invalid API key.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "403": {
        "description": "Forbidden - The client is not authorized to perform the request.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "BadRequest": {
        "description": "Syntactically malformed request, missing required parameter, or unsupported parameter value.",
        "headers": {
          "Request-Id": {
            "$ref": "#/components/headers/RequestId"
          },
          "Content-Language": {
            "$ref": "#/components/headers/ContentLanguage"
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            },
            "examples": {
              "validationFailed": {
                "summary": "Missing or invalid parameter",
                "value": {
                  "type": "https://developer.doit.com/errors/validation_failed",
                  "title": "Validation failed",
                  "status": 400,
                  "detail": "The request is missing a required parameter or contains an invalid value.",
                  "instance": "https://api.doit.com/requests/req_01HX9P2KQVJ8Z3M4T5N6V7W8Y9",
                  "code": "validation_failed",
                  "retryable": false
                }
              },
              "tenantIdRequired": {
                "summary": "Tenant scope not resolvable",
                "value": {
                  "type": "https://developer.doit.com/errors/tenant_id_required",
                  "title": "Tenant ID required",
                  "status": 400,
                  "detail": "X-Tenant-Id header is required when the credential can access more than one tenant.",
                  "instance": "https://api.doit.com/requests/req_01HX9P2KQVJ8Z3M4T5N6V7W8Y9",
                  "code": "tenant_id_required",
                  "retryable": false
                }
              },
              "tenantIdMismatch": {
                "summary": "Header conflicts with the key's tenant",
                "value": {
                  "type": "https://developer.doit.com/errors/tenant_id_mismatch",
                  "title": "Tenant ID mismatch",
                  "status": 400,
                  "detail": "X-Tenant-Id does not match the tenant the credential is scoped to.",
                  "instance": "https://api.doit.com/requests/req_01HX9P2KQVJ8Z3M4T5N6V7W8Y9",
                  "code": "tenant_id_mismatch",
                  "retryable": false
                }
              },
              "gcpServiceRequired": {
                "summary": "GCP region filter without commitment type",
                "value": {
                  "type": "https://developer.doit.com/errors/gcp_service_required",
                  "title": "GCP service required",
                  "status": 400,
                  "detail": "The region query parameter requires gcp_service.",
                  "instance": "https://api.doit.com/requests/req_01HX9P2KQVJ8Z3M4T5N6V7W8Y9",
                  "code": "gcp_service_required",
                  "retryable": false
                }
              },
              "paginationTokenInvalid": {
                "summary": "Structurally invalid pagination cursor",
                "value": {
                  "type": "https://developer.doit.com/errors/pagination_token_invalid",
                  "title": "Invalid pagination token",
                  "status": 400,
                  "detail": "The pageToken cursor is structurally invalid (decode failure or tampering).",
                  "instance": "https://api.doit.com/requests/req_01HX9P2KQVJ8Z3M4T5N6V7W8Y9",
                  "code": "pagination_token_invalid",
                  "retryable": false
                }
              },
              "paginationTokenExpired": {
                "summary": "Expired pagination cursor",
                "value": {
                  "type": "https://developer.doit.com/errors/pagination_token_expired",
                  "title": "Expired pagination token",
                  "status": 400,
                  "detail": "The pageToken cursor is no longer valid; restart pagination from the beginning.",
                  "instance": "https://api.doit.com/requests/req_01HX9P2KQVJ8Z3M4T5N6V7W8Y9",
                  "code": "pagination_token_expired",
                  "retryable": false
                }
              }
            }
          }
        }
      },
      "InternalServerError": {
        "description": "Unexpected server error.",
        "headers": {
          "Request-Id": {
            "$ref": "#/components/headers/RequestId"
          },
          "Content-Language": {
            "$ref": "#/components/headers/ContentLanguage"
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            },
            "example": {
              "type": "https://developer.doit.com/errors/internal_error",
              "title": "Internal server error",
              "status": 500,
              "detail": "an unexpected error occurred",
              "instance": "https://api.doit.com/requests/req_01HX9P2KQVJ8Z3M4T5N6V7W8Y9",
              "code": "internal_error",
              "retryable": true
            }
          }
        }
      },
      "Conflict": {
        "description": "The request conflicts with the current state of the resource.",
        "headers": {
          "Request-Id": {
            "$ref": "#/components/headers/RequestId"
          },
          "Content-Language": {
            "$ref": "#/components/headers/ContentLanguage"
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            },
            "example": {
              "type": "https://developer.doit.com/errors/conflict",
              "title": "Conflict",
              "status": 409,
              "detail": "The requested resource already exists.",
              "instance": "https://api.doit.com/requests/req_01HX9P2KQVJ8Z3M4T5N6V7W8Y9",
              "code": "conflict",
              "retryable": false
            }
          }
        }
      },
      "UnprocessableEntity": {
        "description": "The request is well-formed but a value is not accepted, such as an unknown permission name.",
        "headers": {
          "Request-Id": {
            "$ref": "#/components/headers/RequestId"
          },
          "Content-Language": {
            "$ref": "#/components/headers/ContentLanguage"
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/ProblemDetails"
            },
            "example": {
              "type": "https://developer.doit.com/errors/console-iam.invalid_permission",
              "title": "Invalid permission",
              "status": 422,
              "detail": "invalid permission value",
              "instance": "https://api.doit.com/requests/req_01HX9P2KQVJ8Z3M4T5N6V7W8Y9",
              "code": "console-iam.invalid_permission",
              "retryable": false
            }
          }
        }
      }
    },
    "parameters": {
      "idempotencyKeyRequired": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": true,
        "description": "Client-generated key (UUID v4 or ULID recommended). Retrying with the same key and request returns the stored response instead of repeating the operation; the key is kept for 24 hours.",
        "schema": {
          "type": "string",
          "minLength": 1,
          "maxLength": 255
        }
      },
      "dryRun": {
        "name": "dryRun",
        "in": "query",
        "required": false,
        "description": "If true, validates the request and returns the would-be result without applying it. The response then carries the X-Dry-Run header.",
        "schema": {
          "type": "boolean",
          "default": false
        }
      }
    },
    "securitySchemes": {
      "api_key": {
        "type": "apiKey",
        "name": "Authorization",
        "description": "Use the \"Bearer <API_KEY>\" format or sign in for autofill",
        "in": "header"
      },
      "tenantId": {
        "type": "apiKey",
        "name": "X-Tenant-Id",
        "description": "Customer (tenant) ID for the request. Separate from your API token: always authenticate with `Authorization: Bearer <token>` (personal or service account). See [Get Started](https://developer.doit.com/docs/start). Omit when your token is scoped to a single customer (resolved automatically). A service account can select an active direct or nested descendant of its home customer; the endpoint's normal permissions, entitlements, and resource-ownership checks still apply. A service-account target outside that customer subtree returns `403 Forbidden`. Prefer this header over the legacy `customerContext` query parameter, which only applies to legacy API keys and is ignored by personal and service account tokens.",
        "in": "header"
      }
    },
    "headers": {
      "ETag": {
        "description": "Current version of the resource. Send it unchanged in `If-Match` on the next update or delete.",
        "schema": {
          "type": "string"
        }
      },
      "XDryRun": {
        "description": "Present with the value `true` when the request ran as a dry run and nothing was changed.",
        "schema": {
          "type": "string",
          "enum": [
            "true"
          ]
        }
      },
      "RequestId": {
        "description": "DoiT request identifier for support and log correlation. Format `req_<ULID>`.",
        "schema": {
          "type": "string",
          "pattern": "^req_[0-9A-HJKMNP-TV-Z]{26}$",
          "example": "req_01HX9P2KQVJ8Z3M4T5N6V7W8Y9"
        }
      },
      "ContentLanguage": {
        "description": "Language of the response body. Always `en` for this API.",
        "schema": {
          "type": "string",
          "enum": [
            "en"
          ]
        }
      }
    }
  },
  "x-samples-languages": [
    "curl",
    "go",
    "node",
    "python"
  ],
  "x-cli-config": {
    "security": "oauth2",
    "params": {
      "client_id": "cli"
    }
  }
}
```