openapi: 3.1.0
info:
  title: Geta.Team API
  version: "1.0.0"
  description: |
    Work with Geta.Team from your own backend: follow the workspaces you created
    for your clients and hear of their events through a signed webhook.
    Guide: https://docs.geta.team/docs/api
servers:
  - url: https://dash.geta.team/api/v1
security:
  - apiKey: []
components:
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: A key created in the dashboard, Account, API (gat_sk_...). It works from the IP addresses allowed on it only, and is read-only or read-write.
  schemas:
    Error:
      type: object
      required: [error]
      properties:
        error:
          type: object
          required: [code, message]
          properties:
            code:
              type: string
              enum: [invalid_request, unauthorized, ip_not_allowed, insufficient_scope, not_found, rate_limited, internal_error]
            message: { type: string }
            ip: { type: string, description: "ip_not_allowed only: the address we saw" }
    Workspace:
      type: object
      properties:
        id: { type: integer }
        clientId: { type: integer }
        clientName: { type: string }
        clientEmail: { type: string }
        status: { type: string, description: "provisioning, running, suspended, error..." }
        url: { type: [string, "null"] }
        inviteLink: { type: [string, "null"] }
        inviteStatus: { type: [string, "null"], description: "pending, accepted" }
        startedAt: { type: [string, "null"], format: date-time }
  responses:
    Error:
      description: An error a program can read
      content:
        application/json:
          schema: { $ref: "#/components/schemas/Error" }
paths:
  /me:
    get:
      summary: Check your key
      description: The account the key belongs to.
      responses:
        "200":
          description: The account
          content:
            application/json:
              schema:
                type: object
                properties:
                  id: { type: integer }
                  email: { type: string }
        "401": { $ref: "#/components/responses/Error" }
  /workspaces:
    get:
      summary: List workspaces
      description: The workspaces you created for your clients, newest first (500 at most).
      responses:
        "200":
          description: The workspaces
          content:
            application/json:
              schema:
                type: object
                properties:
                  workspaces:
                    type: array
                    items: { $ref: "#/components/schemas/Workspace" }
        "401": { $ref: "#/components/responses/Error" }
  /workspaces/{id}:
    get:
      summary: Get a workspace
      description: One of the account's workspaces; another account's answers 404.
      parameters:
        - { in: path, name: id, required: true, schema: { type: integer } }
      responses:
        "200":
          description: The workspace
          content:
            application/json:
              schema:
                type: object
                properties:
                  workspace: { $ref: "#/components/schemas/Workspace" }
        "404": { $ref: "#/components/responses/Error" }
webhooks:
  event:
    post:
      summary: Workspace event
      description: |
        Types: workspace.ready, payment.failed, workspace.suspended, workspace.deleted,
        ping. Signed:
        Geta-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256(secret, "<t>.<raw body>")>.
        Answer any 2xx within 10 seconds; otherwise retried after 1, 5, 30 minutes, 2, 6 and 24 hours.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                id: { type: string }
                type: { type: string }
                created: { type: string, format: date-time }
                data: { type: object }
      responses:
        "200": { description: Received }
