> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tracecat.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Workspace Service Account



## OpenAPI

````yaml https://platform.tracecat.com/api/openapi.json post /workspaces/{workspace_id}/service-accounts
openapi: 3.1.0
info:
  title: Tracecat API
  summary: Tracecat API
  description: The open source AI automation platform for security teams and agents.
  termsOfService: >-
    https://docs.google.com/document/d/e/2PACX-1vQvDe3SoVAPoQc51MgfGCP71IqFYX_rMVEde8zC4qmBCec5f8PLKQRdxa6tsUABT8gWAR9J-EVs2CrQ/pub
  contact:
    name: Tracecat Founders
    email: founders@tracecat.com
  license:
    name: AGPL-3.0
    url: https://www.gnu.org/licenses/agpl-3.0.html
  version: '1'
servers:
  - url: /api
security: []
tags:
  - name: public
    description: Public facing endpoints
  - name: workflows
    description: Workflow management
  - name: actions
    description: Action management
  - name: triggers
    description: Workflow triggers
  - name: secrets
    description: Secret management
  - name: variables
    description: Workspace variable management
paths:
  /workspaces/{workspace_id}/service-accounts:
    post:
      tags:
        - service_accounts
      summary: Create Workspace Service Account
      operationId: service_accounts-create_workspace_service_account
      parameters:
        - name: workspace_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Workspace Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ServiceAccountCreate'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServiceAccountApiKeyIssueResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyCookie: []
components:
  schemas:
    ServiceAccountCreate:
      properties:
        name:
          type: string
          maxLength: 255
          minLength: 1
          title: Name
        description:
          anyOf:
            - type: string
              maxLength: 512
            - type: 'null'
          title: Description
        scope_ids:
          items:
            type: string
            format: uuid
          type: array
          title: Scope Ids
        initial_key_name:
          type: string
          maxLength: 255
          minLength: 1
          title: Initial Key Name
          default: Primary
      type: object
      required:
        - name
      title: ServiceAccountCreate
    ServiceAccountApiKeyIssueResponse:
      properties:
        issued_api_key:
          $ref: '#/components/schemas/IssuedServiceAccountApiKey'
        service_account:
          $ref: '#/components/schemas/ServiceAccountRead'
      type: object
      required:
        - issued_api_key
        - service_account
      title: ServiceAccountApiKeyIssueResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    IssuedServiceAccountApiKey:
      properties:
        raw_key:
          type: string
          title: Raw Key
        api_key:
          $ref: '#/components/schemas/ServiceAccountApiKeyRead'
      type: object
      required:
        - raw_key
        - api_key
      title: IssuedServiceAccountApiKey
    ServiceAccountRead:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        organization_id:
          type: string
          format: uuid
          title: Organization Id
        workspace_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Workspace Id
        owner_user_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Owner User Id
        owner_user:
          anyOf:
            - $ref: '#/components/schemas/UserReadMinimal'
            - type: 'null'
        name:
          type: string
          title: Name
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        disabled_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Disabled At
        last_used_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Last Used At
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
        scopes:
          items:
            $ref: '#/components/schemas/ServiceAccountScopeRead'
          type: array
          title: Scopes
        active_api_key:
          anyOf:
            - $ref: '#/components/schemas/ServiceAccountApiKeyRead'
            - type: 'null'
        api_key_counts:
          $ref: '#/components/schemas/ServiceAccountApiKeyCounts'
      type: object
      required:
        - id
        - organization_id
        - name
        - created_at
        - updated_at
      title: ServiceAccountRead
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    ServiceAccountApiKeyRead:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        name:
          type: string
          title: Name
        key_id:
          type: string
          title: Key Id
        preview:
          type: string
          title: Preview
        created_by:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Created By
        created_by_user:
          anyOf:
            - $ref: '#/components/schemas/UserReadMinimal'
            - type: 'null'
        revoked_by:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Revoked By
        revoked_by_user:
          anyOf:
            - $ref: '#/components/schemas/UserReadMinimal'
            - type: 'null'
        last_used_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Last Used At
        revoked_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Revoked At
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
      type: object
      required:
        - id
        - name
        - key_id
        - preview
        - created_at
        - updated_at
      title: ServiceAccountApiKeyRead
    UserReadMinimal:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        email:
          type: string
          format: email
          title: Email
        role:
          $ref: '#/components/schemas/UserRole'
        first_name:
          anyOf:
            - type: string
            - type: 'null'
          title: First Name
        last_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Last Name
      type: object
      required:
        - id
        - email
        - role
      title: UserReadMinimal
    ServiceAccountScopeRead:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        name:
          type: string
          title: Name
        resource:
          type: string
          title: Resource
        action:
          type: string
          title: Action
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
      type: object
      required:
        - id
        - name
        - resource
        - action
      title: ServiceAccountScopeRead
    ServiceAccountApiKeyCounts:
      properties:
        total:
          type: integer
          title: Total
          default: 0
        active:
          type: integer
          title: Active
          default: 0
        revoked:
          type: integer
          title: Revoked
          default: 0
      type: object
      title: ServiceAccountApiKeyCounts
    UserRole:
      type: string
      enum:
        - basic
        - admin
      title: UserRole
  securitySchemes:
    APIKeyCookie:
      type: apiKey
      in: cookie
      name: fastapiusersauth

````