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

# Add Service Accounts To Projects

> Adds a list of service account ids to a list of project ids with the specified role



## OpenAPI

````yaml openapi/service-accounts.openapi.yaml POST /organizations/{organizationId}/service-accounts/add-to-project
openapi: 3.0.2
info:
  title: Service Accounts API
  description: Endpoints for managing service accounts programmatically.
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
  version: 1.0.0
  contact:
    url: https://mixpanel.com/get-support
servers:
  - url: https://{regionAndDomain}.com/api/app
    description: Mixpanel's application API server.
    variables:
      regionAndDomain:
        default: mixpanel
        enum:
          - mixpanel
          - eu.mixpanel
          - in.mixpanel
        description: |
          The server location to be used:
            * `mixpanel` - The default (US) servers used for most projects
            * `eu.mixpanel` - EU servers if you are enrolled in EU Data Residency
            * `in.mixpanel` - India servers if you are enrolled in India Data Residency
security:
  - ServiceAccount: []
tags:
  - name: Create Service Accounts
    description: Operations to add service accounts to an organization
  - name: Delete Service Accounts
    description: Remove a service account from an organization
  - name: Project Membership
    description: Add/remove service accounts to/from projects
  - name: Retrieve Service Accounts
    description: Get details about an organization's service account
paths:
  /organizations/{organizationId}/service-accounts/add-to-project:
    parameters:
      - in: path
        name: organizationId
        schema:
          type: integer
        required: true
        description: 'Your organization id (eg: 12345)'
    post:
      tags:
        - Project Membership
      summary: Add Service Accounts To Projects
      description: >-
        Adds a list of service account ids to a list of project ids with the
        specified role
      operationId: add-service-accounts-to-projects
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddServiceAccountsToProjectsRequest'
      responses:
        '200':
          description: Service accounts added to projects
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    description: '"ok" if the request succeeded, "error" otherwise.'
                    example: ok
                    enum:
                      - ok
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Details about the error that occurred
                  status:
                    type: string
                    enum:
                      - error
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Details about the error that occurred
                  status:
                    type: string
                    enum:
                      - error
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Details about the error that occurred
                  status:
                    type: string
                    enum:
                      - error
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Details about the error that occurred
                  status:
                    type: string
                    enum:
                      - error
components:
  schemas:
    AddServiceAccountsToProjectsRequest:
      type: object
      properties:
        projects:
          type: array
          description: List of project/roles
          items:
            type: object
            properties:
              id:
                type: integer
                description: The project id to add the service account to
              role:
                $ref: '#/components/schemas/RoleEnum'
            required:
              - id
              - role
        service_account_ids:
          type: array
          description: List of service account ids
          items:
            type: integer
      required:
        - projects
        - service_account_ids
    RoleEnum:
      type: string
      description: The service account's role
      enum:
        - owner
        - admin
        - analyst
        - consumer
  securitySchemes:
    ServiceAccount:
      type: http
      scheme: basic
      description: Service Account

````