openapi: 3.1.0
info:
  title: bia cloud API
  version: "1.0"
  summary: Run bias — personal AI agents on computers of their own — and their balance.
  description: |
    The API behind https://cloud.ownbia.com. A person makes an account on the website, then creates an
    API key on the account page and gives it to a script or an agent. With the key, the agent can see the
    account's bias and balance, price an order, open a checkout for the person to pay, and enlarge a bia's
    computer.

    Money: every amount is in euros excluding VAT, as a decimal string ("12.50"). Stripe adds VAT for the
    customer's country at checkout. Brain limits are in US dollars at the AI provider's prices.

    Errors: `{"detail": "message"}`, or for invalid fields `{"field": ["message", …]}`.
    Human-readable docs: https://cloud.ownbia.com/developers/
  contact:
    name: AENGIX, S.L.
    url: https://cloud.ownbia.com/developers/
  termsOfService: https://cloud.ownbia.com/terms/
servers:
  - url: https://cloud-api.ownbia.com
security:
  - apiKey: []
tags:
  - name: Plans
    description: Computers on offer. Public.
  - name: Account
  - name: Balance and bias
  - name: Payments
  - name: Support
    description: The support desk — the one way to ask a person for help or a refund.
  - name: Website session
    description: |
      Used by the website itself, with a session cookie and a CSRF token. Documented for completeness;
      scripts and agents should use an API key instead.

paths:
  /v1:
    get:
      operationId: apiIndex
      tags: [Plans]
      summary: Where the docs are
      security: []
      responses:
        "200":
          description: Links to these docs.
          content:
            application/json:
              schema:
                type: object
                properties:
                  name: { type: string }
                  docs: { type: string, format: uri }
                  openapi: { type: string, format: uri }
                  auth: { type: string }

  /v1/health:
    get:
      operationId: health
      tags: [Plans]
      summary: Is the API up
      security: []
      responses:
        "200":
          description: Up.
          content:
            application/json:
              schema: { type: object, properties: { ok: { type: boolean } } }

  /v1/plans:
    get:
      operationId: listPlans
      tags: [Plans]
      summary: Computers on offer
      description: The `starter` plan is the smallest; an account's first bia always starts on it.
      security: []
      responses:
        "200":
          description: Active plans, smallest first.
          content:
            application/json:
              schema:
                type: object
                properties:
                  plans: { type: array, items: { $ref: "#/components/schemas/Plan" } }
                  vat: { type: string, const: excluded }
                  firstBalanceEur: { type: integer, description: "Put on the balance with an account's first bia, on top of its first month." }

  /v1/auth/me:
    get:
      operationId: getAccount
      tags: [Account]
      summary: The account the key belongs to
      responses:
        "200":
          description: The account.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Me" }
        "401": { $ref: "#/components/responses/Unauthorized" }

  /v1/auth/verify-email/resend:
    post:
      operationId: resendVerification
      tags: [Account]
      summary: Send the email confirmation link again
      responses:
        "204": { description: Sent. }
        "400": { $ref: "#/components/responses/Error" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "429": { $ref: "#/components/responses/TooMany" }
        "503": { description: The email could not be sent right now. }

  /v1/billing/balance:
    get:
      operationId: getBalance
      tags: [Balance and bias]
      summary: Balance, bias and recent activity
      responses:
        "200":
          description: The account's money and bias.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Balance" }
        "401": { $ref: "#/components/responses/Unauthorized" }

  /v1/billing/quote:
    post:
      operationId: quoteOrder
      tags: [Payments]
      summary: What a payment buys
      description: |
        Prices an order without paying. Works without a key too (then as for a new account).
        With `plan`, the order starts a new bia: its first month is taken from the amount and the rest goes
        on the balance. Without `plan`, it is a top-up (the account needs a bia already).
      security: [{ apiKey: [] }, {}]
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/Order" }
            example: { plan: small, amountEur: 30, brain: balance }
      responses:
        "200":
          description: The quote.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Quote" }
        "400": { $ref: "#/components/responses/Error" }
        "503": { description: "Exchange rate unavailable; try again shortly." }

  /v1/billing/checkout:
    post:
      operationId: createCheckout
      tags: [Payments]
      summary: Open a checkout for a person to pay
      description: |
        Returns a Stripe Checkout URL. A person opens it and pays by card; VAT is added there. When paid, the
        money goes on the balance and, for a new bia, the bia is ordered. Watch `/v1/billing/balance` to see it.
        An agent cannot pay by itself: it hands the URL to its person.
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/Order" }
      responses:
        "200":
          description: Where to pay.
          content:
            application/json:
              schema: { type: object, properties: { url: { type: string, format: uri } }, required: [url] }
        "400": { $ref: "#/components/responses/Error" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "502": { description: The payment provider is not reachable. }
        "503": { description: Card payments are not set up yet. }

  /v1/billing/voucher:
    post:
      operationId: useVoucher
      tags: [Payments]
      summary: Put a voucher's amount on the balance
      description: |
        The voucher's amount goes on the balance at once, without a card payment (an activity entry of kind
        `voucher`). Each account can use a voucher once; the account needs a bia (a first bia takes a voucher in
        its checkout instead).
      requestBody:
        required: true
        content:
          application/json:
            schema: { type: object, required: [code], properties: { code: { type: string, example: BIA-K7QM-3XRP } } }
      responses:
        "200": { description: "The balance, as GET /v1/billing/balance." }
        "400": { description: "{ voucher: [why not] }: unknown, expired, used up, or already used on this account." }
        "403": { description: The account is on hold. }
        "429": { $ref: "#/components/responses/TooMany" }

  /v1/billing/bias/{id}/enlarge:
    parameters:
      - { name: id, in: path, required: true, schema: { type: integer } }
    get:
      operationId: listEnlargeOptions
      tags: [Balance and bias]
      summary: Larger computers this bia can move to, and what each costs now
      responses:
        "200":
          description: The options.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/EnlargeOptions" }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "404": { $ref: "#/components/responses/Error" }
    post:
      operationId: enlargeBia
      tags: [Balance and bias]
      summary: Ask for a larger computer (charged only once its server is resized; 202)
      description: |
        Pays the price difference for the rest of the month already paid, from the balance; the new price
        applies from the next month. A computer only grows. This ends the account's money-back guarantee.
      requestBody:
        required: true
        content:
          application/json:
            schema: { type: object, required: [plan], properties: { plan: { type: string, description: Plan code } } }
      responses:
        "200":
          description: Done; the computer restarts once while it is resized.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id: { type: integer }
                  plan: { $ref: "#/components/schemas/Plan" }
        "400":
          description: Not a larger plan, or `code` = `balance` when the balance is too low.
          content:
            application/json:
              schema:
                type: object
                properties: { detail: { type: string }, code: { type: string, enum: [invalid, balance] } }
        "401": { $ref: "#/components/responses/Unauthorized" }
        "404": { $ref: "#/components/responses/Error" }

  /v1/billing/card:
    get:
      operationId: getCard
      tags: [Account]
      summary: The linked card, if any
      responses:
        "200":
          description: The card (brand and last four digits only).
          content:
            application/json:
              schema: { type: object, properties: { card: { $ref: "#/components/schemas/Card" } } }
        "401": { $ref: "#/components/responses/Unauthorized" }
    delete:
      operationId: removeCard
      tags: [Account]
      summary: Unlink the card
      responses:
        "204": { description: Unlinked (or there was none). }
        "401": { $ref: "#/components/responses/Unauthorized" }

  /v1/bias/{id}/brain-key:
    post:
      operationId: giveOwnKey
      tags: [Balance and bias]
      summary: Give an own-key bia its AI key
      description: For a bia whose setupStep is waiting_key. Its computer is made right after; the key goes into the bia and is not kept here.
      parameters: [{ name: id, in: path, required: true, schema: { type: integer } }]
      requestBody:
        required: true
        content:
          application/json:
            schema: { type: object, required: [apiKey], properties: { apiKey: { type: string } } }
      responses:
        "200": { description: Setup started., content: { application/json: { schema: { type: object, properties: { setupStep: { type: string } } } } } }
        "400": { description: Not an API key. }
        "404": { description: No such bia. }
        "409": { description: This bia does not wait for a key. }

  /v1/bias/{id}/delete:
    post:
      operationId: requestBiaDeletion
      tags: [Balance and bias]
      summary: Ask to delete a bia (confirmed by email)
      description: >-
        Nothing is deleted yet. A link goes to the account's email; it works for an hour, and only opening it deletes
        the bia and wipes its computer. A newer request makes older links stop working.
      parameters: [{ name: id, in: path, required: true, schema: { type: integer } }]
      responses:
        "202": { description: The link was sent., content: { application/json: { schema: { type: object, properties: { sent: { type: string } } } } } }
        "404": { description: No such bia. }

  /v1/bias/delete/confirm:
    post:
      operationId: confirmBiaDeletion
      tags: [Website session]
      summary: Delete a bia with the emailed link's token
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema: { type: object, required: [token], properties: { token: { type: string } } }
      responses:
        "200": { description: Deleted., content: { application/json: { schema: { type: object, properties: { id: { type: integer }, status: { type: string } } } } } }
        "400": { description: The link is not valid any more. }

  /v1/bias/{id}/key:
    post:
      operationId: collectBiaKey
      tags: [Website session]
      summary: Collect a bia's root key
      description: >-
        A .biaconfig, a .p12 and ca.crt (base64), under a new password given only in this answer. Possible until the
        key is marked saved; then our copy is gone.
      security: [{ session: [] }]
      parameters: [{ name: id, in: path, required: true, schema: { type: integer } }]
      responses:
        "200": { description: The files and their password. }
        "403": { description: Not with an API key. }
        "409": { description: "Not ready yet, or already saved." }

  /v1/bias/{id}/key/saved:
    post:
      operationId: markBiaKeySaved
      tags: [Website session]
      summary: The key is saved; delete our copy
      security: [{ session: [] }]
      parameters: [{ name: id, in: path, required: true, schema: { type: integer } }]
      responses:
        "200": { description: Our copy is deleted. }
        "403": { description: Not with an API key. }

  /v1/billing/start:
    post:
      operationId: startWithoutAccount
      tags: [Payments]
      summary: Wake up a first bia without an account yet
      description: >-
        Opens a Stripe Checkout for the starter plan's first two weeks plus the first balance. The account is made with
        this email when the payment arrives; Stripe then returns to /welcome, which signs in once
        (POST /v1/auth/checkout-login). 409 with code "account" when the email already has an account.
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [email, acceptTerms]
              properties:
                email: { type: string, format: email }
                name: { type: string, maxLength: 40 }
                lang: { type: string, description: "A language code bia knows, e.g. en, de, es." }
                acceptTerms: { type: boolean }
      responses:
        "200": { description: "{ url } of Stripe Checkout" }
        "409": { description: The email has an account. }

  /v1/billing/brains:
    post:
      operationId: shareBrains
      tags: [Balance and bias]
      summary: Share the balance between the bias' brains
      description: >-
        Every bia has its own OpenRouter key. Its limit is what it already used plus weight ÷ all weights of the
        balance. Weights are whole numbers 0–100.
      requestBody:
        required: true
        content:
          application/json:
            schema: { type: object, required: [shares], properties: { shares: { type: object, additionalProperties: { type: integer, minimum: 0, maximum: 100 } } } }
      responses:
        "200": { description: "The balance, as GET /v1/billing/balance." }
        "400": { description: "Not this account's bias, or a weight out of range." }

  /v1/billing/bias:
    post:
      operationId: startFromBalance
      tags: [Balance and bias]
      summary: Another bia, paid from the balance
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [plan]
              properties:
                plan: { type: string }
                name: { type: string, maxLength: 40 }
                lang: { type: string }
                voucher: { type: string, description: "Used first, together with the start (not at all if the bia can't start)." }
      responses:
        "201": { description: "{ id }" }
        "400": { description: "code balance: the balance can't pay the first two weeks." }

  /v1/support/tickets:
    get:
      operationId: listTickets
      tags: [Support]
      summary: The account's support requests
      responses:
        "200": { description: "{ tickets: [{ id, subject, status, biaId, createdAt, updatedAt }] }" }
    post:
      operationId: openTicket
      tags: [Support]
      summary: Open a support request
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required: [subject, body]
              properties:
                subject: { type: string, maxLength: 200 }
                body: { type: string, maxLength: 20000 }
                biaId: { type: integer }
                files: { type: array, maxItems: 5, items: { type: string, format: binary }, description: "PDF or JPEG, 10 MB each." }
      responses:
        "201": { description: The request with its first message. }
        "400": { description: "Missing text, or a file that is not a PDF or JPEG." }

  /v1/support/tickets/{id}:
    get:
      operationId: getTicket
      tags: [Support]
      summary: One request with its messages
      parameters: [{ name: id, in: path, required: true, schema: { type: integer } }]
      responses:
        "200": { description: "{ id, subject, status, messages: [{ staff, body, at, attachments: [{ id, name, type, size }] }] }" }
        "404": { description: No such request. }

  /v1/support/tickets/{id}/messages:
    post:
      operationId: replyTicket
      tags: [Support]
      summary: Reply to a request
      parameters: [{ name: id, in: path, required: true, schema: { type: integer } }]
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required: [body]
              properties:
                body: { type: string }
                files: { type: array, maxItems: 5, items: { type: string, format: binary } }
      responses:
        "201": { description: The request with all messages. }

  /v1/support/tickets/{id}/close:
    post:
      operationId: closeTicket
      tags: [Support]
      summary: Close a solved request
      parameters: [{ name: id, in: path, required: true, schema: { type: integer } }]
      responses:
        "200": { description: Closed. }

  /v1/support/attachments/{id}:
    get:
      operationId: getAttachment
      tags: [Support]
      summary: Download an attachment
      parameters: [{ name: id, in: path, required: true, schema: { type: integer } }]
      responses:
        "200": { description: The file (application/pdf or image/jpeg). }
        "404": { description: Not one of the account's. }

  /v1/billing/portal:
    post:
      operationId: openBillingPortal
      tags: [Website session]
      summary: Open Stripe's billing page
      description: A short-lived link to Stripe's customer portal, to replace or remove the card and download invoices.
      security: [{ session: [] }]
      responses:
        "200":
          description: Redirect the person to url.
          content:
            application/json:
              schema: { type: object, properties: { url: { type: string, format: uri } } }
        "403": { description: Not with an API key. }
        "404": { description: No payment was made from this account yet. }

  /v1/auth/keys:
    get:
      operationId: listApiKeys
      tags: [Website session]
      summary: List API keys
      security: [{ session: [] }]
      responses:
        "200":
          description: The keys (never the keys themselves).
          content:
            application/json:
              schema: { type: object, properties: { keys: { type: array, items: { $ref: "#/components/schemas/ApiKey" } } } }
        "403": { description: Not with an API key. }
    post:
      operationId: createApiKey
      tags: [Website session]
      summary: Create an API key
      description: The key is in the answer once and never again. At most 10 keys per account.
      security: [{ session: [] }]
      requestBody:
        required: true
        content:
          application/json:
            schema: { type: object, required: [name], properties: { name: { type: string, maxLength: 80 } } }
      responses:
        "201":
          description: The new key.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/ApiKey"
                  - type: object
                    properties: { key: { type: string, example: bck_3fA9xK2… } }
        "400": { $ref: "#/components/responses/Error" }
        "403": { description: Not with an API key. }
  /v1/auth/keys/{id}:
    delete:
      operationId: revokeApiKey
      tags: [Website session]
      summary: Revoke an API key
      security: [{ session: [] }]
      parameters:
        - { name: id, in: path, required: true, schema: { type: integer } }
      responses:
        "204": { description: Revoked. }

  /v1/auth/csrf:
    get:
      operationId: getCsrfToken
      tags: [Website session]
      summary: Get a CSRF token (sets the csrftoken cookie)
      security: []
      responses:
        "200":
          description: The token, to send back as `X-CSRFToken`.
          content:
            application/json:
              schema: { type: object, properties: { csrfToken: { type: string } } }
  /v1/auth/signup:
    post:
      operationId: signup
      tags: [Website session]
      summary: Create an account (and sign in)
      description: Accounts are made by people, who accept the terms of service and refund policy.
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [email, password, accept_terms]
              properties:
                email: { type: string, format: email }
                password: { type: string, minLength: 10 }
                name: { type: string, maxLength: 150 }
                accept_terms: { type: boolean, const: true }
      responses:
        "201": { description: Created; a confirmation link is emailed., content: { application/json: { schema: { $ref: "#/components/schemas/Me" } } } }
        "400": { $ref: "#/components/responses/Error" }
        "429": { $ref: "#/components/responses/TooMany" }
  /v1/auth/login:
    post:
      operationId: login
      tags: [Website session]
      summary: Sign in
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema: { type: object, required: [email, password], properties: { email: { type: string }, password: { type: string } } }
      responses:
        "200": { description: Signed in., content: { application/json: { schema: { $ref: "#/components/schemas/Me" } } } }
        "400": { $ref: "#/components/responses/Error" }
        "429": { $ref: "#/components/responses/TooMany" }
  /v1/auth/logout:
    post:
      operationId: logout
      tags: [Website session]
      summary: Sign out
      security: []
      responses:
        "204": { description: Signed out. }
  /v1/auth/email:
    post:
      operationId: changeEmail
      tags: [Website session]
      summary: Change the account's email
      security: [{ session: [] }]
      requestBody:
        required: true
        content:
          application/json:
            schema: { type: object, required: [email, password], properties: { email: { type: string, format: email }, password: { type: string } } }
      responses:
        "200":
          description: Changed; the new address must be confirmed.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/Me"
                  - type: object
                    properties: { verificationSent: { type: boolean } }
        "400": { $ref: "#/components/responses/Error" }
        "403": { description: Not with an API key. }
  /v1/auth/verify-email:
    post:
      operationId: verifyEmail
      tags: [Website session]
      summary: Confirm an email with the token from the link
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema: { type: object, required: [token], properties: { token: { type: string } } }
      responses:
        "204": { description: Confirmed. }
        "400": { $ref: "#/components/responses/Error" }
  /v1/auth/password/reset:
    post:
      operationId: requestPasswordReset
      tags: [Website session]
      summary: Email a password reset link
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema: { type: object, required: [email], properties: { email: { type: string, format: email } } }
      responses:
        "204": { description: Sent if the account exists (the answer is the same either way). }
        "429": { $ref: "#/components/responses/TooMany" }
  /v1/auth/password/reset/confirm:
    post:
      operationId: confirmPasswordReset
      tags: [Website session]
      summary: Set a new password with the uid and token from the link
      security: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [uid, token, password]
              properties: { uid: { type: string }, token: { type: string }, password: { type: string, minLength: 10 } }
      responses:
        "204": { description: Changed; every signed-in session ends. }
        "400": { $ref: "#/components/responses/Error" }

components:
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: An API key from the account page, `bck_…`. No cookies or CSRF token needed.
    session:
      type: apiKey
      in: cookie
      name: sessionid
      description: The website's session; state-changing requests also need the `X-CSRFToken` header.

  responses:
    Error:
      description: Something about the request is wrong.
      content:
        application/json:
          schema: { $ref: "#/components/schemas/Error" }
    Unauthorized:
      description: No API key, or an unknown or revoked one.
      content:
        application/json:
          schema: { $ref: "#/components/schemas/Error" }
    TooMany:
      description: Too many requests; try again later.

  schemas:
    Money:
      type: string
      pattern: '^-?\d+\.\d{2}$'
      description: Euros excluding VAT, e.g. "12.50".
    Error:
      type: object
      properties: { detail: { type: string } }
      additionalProperties: { type: array, items: { type: string } }
    Plan:
      type: object
      properties:
        code: { type: string, example: small }
        name: { type: string, example: 2 vCores · 4 GB }
        vcores: { type: integer }
        memoryGb: { type: integer }
        diskGb: { type: integer }
        priceEur: { $ref: "#/components/schemas/Money" }
        periodEur: { $ref: "#/components/schemas/Money", description: "What two weeks cost: billed every two weeks from the balance (a month × 12 / 26)." }
        starter: { type: boolean, description: The smallest plan; every account's first bia starts on it. }
    Card:
      type: [object, "null"]
      properties:
        brand: { type: string }
        last4: { type: string }
        expMonth: { type: integer }
        expYear: { type: integer }
    Me:
      type: object
      properties:
        email: { type: string, format: email }
        name: { type: string }
        termsAcceptedAt: { type: [string, "null"], format: date-time }
        emailVerified: { type: boolean }
        card: { $ref: "#/components/schemas/Card" }
    Order:
      type: object
      required: [amountEur]
      properties:
        amountEur:
          type: integer
          minimum: 10
          maximum: 1000
          description: |
            Whole euros, excluding VAT; with a plan, at least the plan's monthly price. Required, except for an
            account's first bia: that payment is fixed (the starter plan's first month + `firstBalanceEur` from
            /v1/plans on the balance) and any amount sent is ignored.
        plan:
          type: string
          description: For a new bia. An account's first bia must use the starter plan. Omit to top up.
        brain:
          type: string
          enum: [balance, own]
          default: balance
          description: "`balance`: the bia's brain is paid from the balance. `own`: its own AI key or subscription."
        voucher:
          type: string
          description: |
            A voucher code. It pays part of this order: the card pays the rest, at least €1, and the balance gets
            both. A voucher that covers the whole order leaves nothing to pay (amountEur 0): the checkout then only
            checks the card, without a charge. While the checkout is open (up to an hour) the voucher is held for it.
    Quote:
      type: object
      properties:
        amountEur: { $ref: "#/components/schemas/Money", description: "What the card pays (excluding VAT)." }
        voucherEur: { type: [string, "null"], description: "What the voucher adds, when one was sent." }
        hostingEur: { $ref: "#/components/schemas/Money" }
        brainEur: { $ref: "#/components/schemas/Money" }
        markupPct: { type: number, description: Added to the AI provider's price for brain usage from the balance. }
        eurUsd: { type: string, description: The exchange rate used (brain from the balance only). }
        brainLimitUsd: { type: string, description: "What the brain can then spend: USD at provider prices." }
        vat: { type: string }
    Bia:
      type: object
      properties:
        id: { type: integer }
        plan: { $ref: "#/components/schemas/Plan" }
        brain: { type: string, enum: [balance, own] }
        status:
          type: string
          enum: [ordered, active, paused, closed]
          description: "`ordered`: its computer is being set up."
        createdAt: { type: string, format: date-time }
        paidUntil: { type: [string, "null"], format: date-time }
        canEnlarge: { type: boolean }
        setupStep:
          type: string
          enum: ["", waiting_key, queued, ordering, installing, starting, ready, failed, deleted]
          description: Where making its computer is. `waiting_key` — an own-key bia needs its AI key (POST /v1/bias/{id}/brain-key).
        setupError: { type: string }
        address: { type: [string, "null"], description: "Where the bia answers: https://<address>/ (with its key)." }
        keyWaiting: { type: boolean, description: "Root's key is ready to collect on the website." }
        brainShare: { type: integer, description: "Its weight in sharing the balance between brains (0–100)." }
        brainPct: { type: integer, description: "Its share of the balance for brains, in percent." }
        brainLeftUsd: { type: [string, "null"], description: "What its brain key can still spend (USD, provider prices)." }
        brainSpentEur: { $ref: "#/components/schemas/Money" }
        webUrl: { type: [string, "null"], description: "The bia's own page (opens with its key in the browser)." }
        appUrl: { type: [string, "null"], description: "An ownbia.com/open link the bia deploy apps open." }
    Balance:
      type: object
      properties:
        balanceEur: { $ref: "#/components/schemas/Money" }
        brainLimitUsd: { type: [string, "null"] }
        brainLeftUsd: { type: [string, "null"], description: "What the brain can still spend: USD at provider prices." }
        monthlyEur: { $ref: "#/components/schemas/Money" }
        minTopUpEur: { type: integer }
        card:
          oneOf: [{ $ref: "#/components/schemas/Card" }, { type: "null" }]
          description: The saved card, or null.
        portal: { type: boolean, description: "Stripe's billing page can be opened (POST /v1/billing/portal)." }
        moneyBack:
          type: [object, "null"]
          description: Open no-questions refund of the first computer's fee; ends at the first change.
          properties:
            amountEur: { $ref: "#/components/schemas/Money" }
            until: { type: string, format: date-time }
        hold:
          type: [object, "null"]
          description: >-
            Set when the account is stopped after a refund or a chargeback. All its bias are paused, the brain key is
            off, and checkout and enlarge answer 403 with code "hold".
          properties:
            reason: { type: string, enum: [refund, dispute] }
            since: { type: string, format: date-time }
        bias: { type: array, items: { $ref: "#/components/schemas/Bia" } }
        entries:
          type: array
          description: The last 50 balance movements, newest first.
          items:
            type: object
            properties:
              at: { type: string, format: date-time }
              kind: { type: string, enum: [topup, hosting, brain, refund, adjustment, voucher] }
              amountEur: { $ref: "#/components/schemas/Money" }
              note: { type: string }
    EnlargeOptions:
      type: object
      properties:
        current: { $ref: "#/components/schemas/Plan" }
        paidUntil: { type: [string, "null"], format: date-time }
        balanceEur: { $ref: "#/components/schemas/Money" }
        endsMoneyBack: { type: boolean }
        options:
          type: array
          items:
            type: object
            properties:
              plan: { $ref: "#/components/schemas/Plan" }
              chargeEur: { $ref: "#/components/schemas/Money", description: Taken from the balance now. }
    ApiKey:
      type: object
      properties:
        id: { type: integer }
        name: { type: string }
        start: { type: string, description: "The first characters, to recognise the key." }
        createdAt: { type: string, format: date-time }
        lastUsedAt: { type: [string, "null"], format: date-time }
