---
updatedAt: 2026-09-30T09:07:12.000Z
agentTools:
  projectIndex: https://developer.doit.com/llms.txt
---

# List API tokens for a service account

Returns the service account's non-deleted API tokens in a single unpaginated `items` array, at most 10. Secret material is never returned here — `accessToken` is shown only once, by the create operation. Requires the `serviceAccountViewer` 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/{serviceAccountId}/api-tokens": {
      "parameters": [
        {
          "$ref": "#/components/parameters/serviceAccountTokenParentId"
        }
      ],
      "get": {
        "tags": [
          "Service Accounts"
        ],
        "summary": "List API tokens for a service account",
        "description": "Returns the service account's non-deleted API tokens in a single unpaginated `items` array, at most 10. Secret material is never returned here — `accessToken` is shown only once, by the create operation. Requires the `serviceAccountViewer` permission.",
        "operationId": "listServiceAccountTokens",
        "responses": {
          "200": {
            "description": "OK - API tokens returned.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceAccountTokensResponse"
                },
                "example": {
                  "items": [
                    {
                      "id": "Mr0sN7pQ4tU2vW5xY8zC",
                      "serviceAccountId": "Lq3nO9rM5wS2tU0xY4zA",
                      "customerId": "Kp2mN8qL4vR0sT1wX3yZ",
                      "name": "ci-pipeline-prod",
                      "state": "active",
                      "createTime": "2026-09-01T08:00:00Z",
                      "expiresTime": "2027-09-01T08:00:00Z",
                      "lastUsedTime": "2026-09-20T14:31:00Z"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/401"
          },
          "403": {
            "$ref": "#/components/responses/403"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ServiceAccountToken": {
        "type": "object",
        "description": "An API token of a service account. It authenticates with the service account's permissions, and carries no secret material after the create response.",
        "required": [
          "id",
          "serviceAccountId",
          "customerId",
          "name",
          "state",
          "createTime",
          "expiresTime",
          "lastUsedTime"
        ],
        "properties": {
          "id": {
            "type": "string",
            "nullable": true,
            "readOnly": true,
            "description": "API token ID. `null` only on a dry-run create.",
            "example": "Mr0sN7pQ4tU2vW5xY8zC"
          },
          "serviceAccountId": {
            "type": "string",
            "readOnly": true,
            "description": "ID of the service account that owns the token.",
            "example": "Lq3nO9rM5wS2tU0xY4zA"
          },
          "customerId": {
            "type": "string",
            "readOnly": true,
            "description": "ID of the customer whose service account the token belongs to.",
            "example": "Kp2mN8qL4vR0sT1wX3yZ"
          },
          "name": {
            "type": "string",
            "description": "Name, unique among the service account's tokens.",
            "example": "ci-pipeline-prod"
          },
          "state": {
            "type": "string",
            "enum": [
              "active",
              "disabled"
            ],
            "description": "The token's stored state: `active` while it is enabled, `disabled` once it has been turned off. This is not a liveness signal — a token whose `expiresTime` has passed stops authenticating but keeps the state it was stored with, so `active` here does not by itself mean the token still works; compare `expiresTime`. Only these two values can be set.",
            "example": "active"
          },
          "createTime": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "readOnly": true,
            "description": "When the token was created. `null` only on a dry-run create.",
            "example": "2026-09-01T08:00:00Z"
          },
          "expiresTime": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the token stops authenticating. `null` when it does not expire.",
            "example": "2027-09-01T08:00:00Z"
          },
          "lastUsedTime": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "readOnly": true,
            "description": "When the token last authenticated a request. `null` until it is first used.",
            "example": "2026-09-20T14:31:00Z"
          }
        }
      },
      "ServiceAccountTokensResponse": {
        "type": "object",
        "description": "API tokens of a service account, at most 10.",
        "required": [
          "items"
        ],
        "properties": {
          "items": {
            "type": "array",
            "maxItems": 10,
            "description": "The service account's non-deleted API tokens.",
            "items": {
              "$ref": "#/components/schemas/ServiceAccountToken"
            },
            "example": [
              {
                "id": "Mr0sN7pQ4tU2vW5xY8zC",
                "serviceAccountId": "Lq3nO9rM5wS2tU0xY4zA",
                "customerId": "Kp2mN8qL4vR0sT1wX3yZ",
                "name": "ci-pipeline-prod",
                "state": "active",
                "createTime": "2026-09-01T08:00:00Z",
                "expiresTime": "2027-09-01T08:00:00Z",
                "lastUsedTime": "2026-09-20T14:31:00Z"
              }
            ]
          }
        }
      },
      "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"
            }
          }
        }
      },
      "NotFound": {
        "description": "The requested resource does not exist.",
        "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/not_found",
              "title": "Resource not found",
              "status": 404,
              "detail": "organization not found",
              "instance": "https://api.doit.com/requests/req_01HX9P2KQVJ8Z3M4T5N6V7W8Y9",
              "code": "not_found",
              "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
            }
          }
        }
      }
    },
    "parameters": {
      "serviceAccountTokenParentId": {
        "name": "serviceAccountId",
        "in": "path",
        "required": true,
        "description": "ID of the service account that owns the token, as returned in the id field by the service account list and create operations.",
        "schema": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "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": {
      "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"
    }
  }
}
```