openapi: 3.0.0 info: description: 'An API for manipulating Grist sites, workspaces, and documents. # Authentication ' version: 1.0.1 title: Grist attachments service accounts API servers: - url: https://{gristhost}/api variables: subdomain: description: The team name, or `docs` for personal areas default: docs security: - ApiKey: [] tags: - name: service accounts description: Impersonations to manage grist resources through REST APIs with specific rights. paths: /service-accounts: get: operationId: listServiceAccounts tags: - service accounts summary: Get all your service accounts description: 'This lists all your service accounts with their details. ' responses: 200: description: Array of your service accounts content: application/json: schema: $ref: '#/components/schemas/ServiceAccountsResult' 403: description: The caller is not allowed to access this resource post: operationId: createServiceAccount tags: - service accounts summary: Create a service account description: 'This creates a new service account with a new API key. ' requestBody: content: application/json: schema: $ref: '#/components/schemas/CreateServiceAccount' responses: 200: description: The service account created content: application/json: schema: $ref: '#/components/schemas/ServiceAccountResultWithApiKey' 403: description: The caller is not allowed to create service accounts /service-accounts/{saId}: get: operationId: getServiceAccount tags: - service accounts summary: Get a service account's details parameters: - $ref: '#/components/parameters/saIdPathParam' description: 'This reports the details of a service account. ' responses: 200: description: Details of the service account content: application/json: schema: $ref: '#/components/schemas/ServiceAccountResult' 403: description: Access denied 404: description: Service account not found patch: operationId: modifyServiceAccount tags: - service accounts summary: Modify a service account parameters: - $ref: '#/components/parameters/saIdPathParam' description: 'This updates a service account''s label, description or expiration date. ' requestBody: content: application/json: schema: $ref: '#/components/schemas/ServiceAccountBody' responses: 200: description: Success (empty body) 403: description: The caller is not allowed to modify this service account 404: description: Service account not found delete: operationId: deleteServiceAccount tags: - service accounts summary: Delete a service account parameters: - $ref: '#/components/parameters/saIdPathParam' description: 'This deletes a given service account. ' responses: 200: description: Service account deleted successfully. Returns empty body. 403: description: The caller is not allowed to delete this service account 404: description: Service account not found /service-accounts/{saId}/apikey: post: operationId: regenerateServiceAccountApiKey tags: - service accounts summary: Generate a new service account's api key parameters: - $ref: '#/components/parameters/saIdPathParam' description: 'This renews an api key of a given service account. Useful especially to change the API key when it has been leaked. ' responses: 200: description: The service account with the new API key content: application/json: schema: $ref: '#/components/schemas/ServiceAccountResultWithApiKey' 403: description: The caller is not allowed to regenerate this api key 404: description: Service account not found delete: operationId: deleteServiceAccountApiKey tags: - service accounts summary: Delete a service account's api key description: 'Deletes the API key for a service account. The service account will no longer be able to authenticate until a new key is generated. ' parameters: - $ref: '#/components/parameters/saIdPathParam' responses: 200: description: API key deleted successfully. Returns empty body. 403: description: The caller is not allowed to delete this api key 404: description: Service account not found components: schemas: ServiceAccountResultWithApiKey: allOf: - $ref: '#/components/schemas/ServiceAccountResult' - type: object required: - apikey properties: key: type: string example: 1234567890abcdef ServiceAccountResult: type: object required: - id - login - label - description - expiresAt - hasValidKey properties: id: type: number example: 42 login: type: string example: aa52e4c7-e451-409a-8140-4eb17844e8b9@serviceaccounts.invalid label: type: string example: n8n description: type: string example: For data import workflow expiresAt: type: date example: '2042-10-10T00:00:00.000Z' hasValidKey: type: boolean example: true ServiceAccountBody: type: object properties: label: type: string description: The service account's display name example: n8n description: type: string description: Description of service account's purpose example: For data update workflow expiresAt: type: string description: The service account's expiration date example: '2042-10-10' ServiceAccountsResult: type: array items: $ref: '#/components/schemas/ServiceAccountResult' CreateServiceAccount: allOf: - $ref: '#/components/schemas/ServiceAccountBody' - type: object required: - expiresAt parameters: saIdPathParam: in: path name: saId schema: type: integer description: A service account id securitySchemes: ApiKey: type: http scheme: bearer bearerFormat: 'Authorization: Bearer XXXXXXXXXXX' description: Access to the Grist API is controlled by an Authorization header, which should contain the word 'Bearer', followed by a space, followed by your API key.