API reference

Base URL http://ask2cents.com. Requests and responses are JSON. The same reference is available as openapi.json.

Endpoints marked signed in need a Clerk session: browsers on this site send it as a cookie; other clients send Authorization: Bearer <session token>.

GET/api/health

Check that the Worker is up. Public.

Answers without touching D1 or any provider, so a smoke check can tell the Worker from its dependencies.

Responses

200 The Worker is serving, and the target it was built for.

{
  "type": "object",
  "properties": {
    "ok": {
      "type": "boolean",
      "const": true
    },
    "target": {
      "type": "string",
      "enum": [
        "local",
        "preview",
        "production"
      ]
    }
  },
  "required": [
    "ok",
    "target"
  ],
  "additionalProperties": false
}

GET/api/me

Who is signed in. Signed in.

The caller's Clerk ids and the subject that owns data and pays: the user in b2c, the active workspace in b2b.

Responses

200 The signed-in caller.

{
  "type": "object",
  "properties": {
    "userId": {
      "type": "string"
    },
    "organizationId": {
      "type": [
        "string",
        "null"
      ]
    },
    "organizationRole": {
      "type": [
        "string",
        "null"
      ]
    },
    "subjectId": {
      "type": "string"
    }
  },
  "required": [
    "userId",
    "organizationId",
    "organizationRole",
    "subjectId"
  ],
  "additionalProperties": false
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

DELETE/api/me

Delete my account. Signed in.

Deletes the caller's Clerk user, which signs them out everywhere, then erases everything the product holds about them, as Clerk's `user.deleted` webhook does: in b2c their plan is cancelled first, then their files, their Loops contact and their D1 rows go. Needs a sign-in or reverification within 10 minutes (Clerk's `strict` preset); the app calls it through Clerk's `useReverification()`.

Responses

200 Deleted.

{
  "type": "object",
  "properties": {
    "deleted": {
      "type": "boolean",
      "const": true
    }
  },
  "required": [
    "deleted"
  ],
  "additionalProperties": false
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 Signed in too long ago: Clerk's reverification error (`clerk_error.reason` is `reverification-error`), or, in b2b, no active workspace (`organization_required`).

{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "error": {
          "type": "string"
        }
      },
      "required": [
        "error"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "clerk_error": {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "forbidden"
            },
            "reason": {
              "type": "string",
              "const": "reverification-error"
            },
            "metadata": {
              "type": "object",
              "properties": {
                "reverification": {
                  "type": "string"
                }
              },
              "required": [
                "reverification"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "type",
            "reason",
            "metadata"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "clerk_error"
      ],
      "additionalProperties": false
    }
  ]
}

502 Clerk didn't delete the user; nothing was erased, so trying again is safe (`account_not_deleted`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

GET/api/me/export

Download my data. Signed in.

Everything the product holds about the caller, as a JSON file (`Content-Disposition: attachment`): their Clerk profile (names, email addresses, phone numbers, connected accounts), their Loops email contact (its properties and the mailing lists it is on), their account row, Product news consent, the files stored for them, and every table keyed to them.

Responses

200 The export.

{
  "type": "object",
  "properties": {
    "exportedAt": {
      "type": "string"
    },
    "account": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "createdAt": {
              "type": [
                "string",
                "null"
              ]
            },
            "lastSeenAt": {
              "type": [
                "string",
                "null"
              ]
            },
            "activatedAt": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "id",
            "createdAt",
            "lastSeenAt",
            "activatedAt"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    },
    "profile": {
      "anyOf": [
        {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {}
        },
        {
          "type": "null"
        }
      ]
    },
    "emailContact": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "properties": {
              "type": "object",
              "propertyNames": {
                "type": "string"
              },
              "additionalProperties": {}
            },
            "mailingLists": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "id",
                  "name"
                ],
                "additionalProperties": false
              }
            }
          },
          "required": [
            "properties",
            "mailingLists"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    },
    "productNews": {
      "type": "object",
      "properties": {
        "status": {
          "type": "string",
          "enum": [
            "off",
            "pending",
            "on"
          ],
          "description": "`pending` until the person clicks the link in the confirmation email."
        },
        "requestedAt": {
          "type": [
            "string",
            "null"
          ]
        },
        "confirmedAt": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "status",
        "requestedAt",
        "confirmedAt"
      ],
      "additionalProperties": false
    },
    "files": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "size": {
            "type": "number"
          },
          "uploadedAt": {
            "type": "string"
          }
        },
        "required": [
          "key",
          "size",
          "uploadedAt"
        ],
        "additionalProperties": false
      }
    },
    "data": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {
        "type": "array",
        "items": {}
      }
    }
  },
  "required": [
    "exportedAt",
    "account",
    "profile",
    "emailContact",
    "productNews",
    "files",
    "data"
  ],
  "additionalProperties": false
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

502 Clerk or Loops couldn't be read, so the export would miss the profile or the email contact (`export_unavailable`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

GET/api/news

Your Product news consent. Signed in.

Whether the signed-in person gets Product news (marketing email): `off`, `pending` (asked, not confirmed) or `on`.

Responses

200 The consent.

{
  "type": "object",
  "properties": {
    "status": {
      "type": "string",
      "enum": [
        "off",
        "pending",
        "on"
      ],
      "description": "`pending` until the person clicks the link in the confirmation email."
    }
  },
  "required": [
    "status"
  ],
  "additionalProperties": false
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

POST/api/news

Ask for Product news. Signed in.

Double opt-in: queues a `news-confirm` email whose signed link (3 days, newest only) turns consent `on` once clicked. At most one email per five minutes; a repeat inside that window answers `pending` and sends none.

Responses

200 Already `on`; nothing sent.

{
  "type": "object",
  "properties": {
    "status": {
      "type": "string",
      "const": "on"
    }
  },
  "required": [
    "status"
  ],
  "additionalProperties": false
}

202 `pending`: the confirmation email is queued (or was, under five minutes ago).

{
  "type": "object",
  "properties": {
    "status": {
      "type": "string",
      "const": "pending"
    }
  },
  "required": [
    "status"
  ],
  "additionalProperties": false
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk or `NEWS_SIGNING_SECRET` isn't configured for this target (`news_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

DELETE/api/news

Stop Product news. Signed in.

Turns consent `off` at once and queues the person's Loops contact to leave the Product news list and be unsubscribed.

Responses

200 Off.

{
  "type": "object",
  "properties": {
    "status": {
      "type": "string",
      "const": "off"
    }
  },
  "required": [
    "status"
  ],
  "additionalProperties": false
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

POST/api/webhooks/clerk

Receive Clerk events. Provider webhook.

Called by Clerk through Svix. Each delivery runs once: a redelivered `svix-id` answers 200 with `duplicate: true` without running again. `email.created` (with "Delivered by Clerk" off) queues Clerk's email for sending through Loops, in the template for its type; one Clerk already delivered, or to a `+clerk_test` address, is ignored. Called by the provider; the request is verified by its signature.

Responses

200 Handled, ignored (an event type the product doesn't use) or a duplicate delivery.

{
  "type": "object",
  "properties": {
    "ok": {
      "type": "boolean",
      "const": true
    },
    "duplicate": {
      "type": "boolean"
    },
    "ignored": {
      "type": "string"
    }
  },
  "required": [
    "ok"
  ],
  "additionalProperties": false
}

400 The Svix signature is missing, invalid or stale.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 No signing secret is set, or handling failed (the `email` queue included); Svix retries.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

POST/api/webhooks/loops

Receive Loops events. Provider webhook.

Called by Loops, signed Standard Webhooks style with `LOOPS_WEBHOOK_SECRET`. Delivery events become log lines naming the template, never the address: `email.delivered`, `email.hardBounced` as `email.bounced` and `email.spamReported` as `email.complained`. An unsubscribe moves the person's Product news consent to `off`: `contact.unsubscribed`, or `contact.mailingList.unsubscribed` from the Product news list. Each delivery runs once: a redelivered `webhook-id` answers 200 with `duplicate: true`. Called by the provider; the request is verified by its signature.

Responses

200 Handled, ignored (an event type the product doesn't use) or a duplicate delivery.

{
  "type": "object",
  "properties": {
    "ok": {
      "type": "boolean",
      "const": true
    },
    "duplicate": {
      "type": "boolean"
    },
    "ignored": {
      "type": "string"
    }
  },
  "required": [
    "ok"
  ],
  "additionalProperties": false
}

400 The signature is missing, invalid or stale.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 No `LOOPS_WEBHOOK_SECRET` is set, or handling failed; Loops retries.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

GET/api/files/download

Download a file through a signed link. Public.

The link that `signDownloadLink()` hands out from a product route that owns the file. It needs no session and works for whoever holds it until it expires (5 minutes at most). The file always downloads (`Content-Disposition: attachment`, `nosniff`).

Parameters

NameInRequiredSchema
keyqueryyes{"type":"string","description":"The file's storage key, as the link carries it."}
expiresqueryyes{"type":"string","description":"Expiry, in Unix seconds."}
signaturequeryyes{"type":"string","description":"HMAC-SHA256 of key and expiry."}

Responses

200 The file's bytes, with its content type.

403 The link is expired, or its key, expiry or signature was edited.

404 The file no longer exists.

503 `STORAGE_SIGNING_SECRET` isn't set for this target.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

POST/api/billing/checkout

Start a Stripe Checkout. Signed in.

Opens a Stripe Checkout Session (Managed Payments) for the signed-in subject: a plan from the catalog by its key, or a credit pack under the `credits` model. Prices come from the catalog by lookup key; the client never names a Stripe price. The plan is granted only once Stripe's signed webhook confirms it.

Request body

{
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "plan": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        },
        "interval": {
          "type": "string",
          "enum": [
            "month",
            "year"
          ]
        }
      },
      "required": [
        "plan"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "pack": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64
        }
      },
      "required": [
        "pack"
      ],
      "additionalProperties": false
    }
  ]
}

Responses

201 Redirect the browser to `url`, Stripe's hosted Checkout.

{
  "type": "object",
  "properties": {
    "url": {
      "type": "string"
    }
  },
  "required": [
    "url"
  ],
  "additionalProperties": false
}

400 The body is neither `{ plan, interval? }` nor `{ pack }` (`Validation failed`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "`Validation failed`, or `Invalid JSON body`."
    },
    "issues": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "slot": {
            "type": "string",
            "enum": [
              "body",
              "query",
              "params"
            ]
          },
          "issues": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string"
                },
                "path": {
                  "type": "string"
                }
              },
              "required": [
                "message"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "slot",
          "issues"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`), on a personal account, which has no billing (`no_organization`), or not an admin of the active workspace (`not_admin`). Nothing reaches Stripe.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

404 Billing is off for this target: no Stripe key, or a key of the wrong mode (`billing_off`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

409 The subject already has a subscription that grants access; change it in the portal (`already_subscribed`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

422 No such plan, a plan this model can't sell, or packs under a model without credits (`unknown_plan`, `packs_not_sold`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured, Stripe has no active price for a lookup key (`price_not_found`), or Stripe failed (`billing_unavailable`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

POST/api/billing/portal

Open the Stripe customer portal. Signed in.

A Stripe customer portal session on the subject's own Customer, once it has paid for a subscription or a credit pack: payment methods, invoices, cancelling. It returns to `/app/billing?portal=returned`.

Responses

201 Redirect the browser to `url`.

{
  "type": "object",
  "properties": {
    "url": {
      "type": "string"
    }
  },
  "required": [
    "url"
  ],
  "additionalProperties": false
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`), on a personal account, which has no billing (`no_organization`), or not an admin of the active workspace (`not_admin`). Nothing reaches Stripe.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

404 Billing is off for this target (`billing_off`), or the subject has no paid subscription or credit pack, even if it opened a Checkout (`no_billing_account`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured, or Stripe failed (`billing_unavailable`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

POST/api/webhooks/stripe

Receive Stripe events. Provider webhook.

Called by Stripe, signed with the endpoint's secret (`Stripe-Signature`, five minutes' tolerance). It is the only writer of billing state. Each event runs once: a redelivered event id answers 200 with `duplicate: true`, and an event older than the stored state never overwrites it. Called by the provider; the request is verified by its signature.

Responses

200 Handled, ignored (an event type or Customer billing doesn't act on) or a duplicate delivery.

{
  "type": "object",
  "properties": {
    "ok": {
      "type": "boolean",
      "const": true
    },
    "duplicate": {
      "type": "boolean"
    },
    "ignored": {
      "type": "string"
    }
  },
  "required": [
    "ok"
  ],
  "additionalProperties": false
}

400 The signature is missing, invalid or stale (`invalid_signature`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

404 Billing is off for this target (`billing_off`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 No signing secret is set, or handling failed or must wait for an earlier event; Stripe retries.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

GET/api/my/key

My key and balance. Signed in.

The caller's primary key hint (never the secret) and 2¢ balance, split free/bought.

Responses

200 Key hint and balance.

{
  "type": "object",
  "properties": {
    "key_hint": {
      "type": [
        "string",
        "null"
      ]
    },
    "credits": {
      "type": "number"
    },
    "free_credits": {
      "type": "number"
    },
    "bought_credits": {
      "type": "number"
    }
  },
  "required": [
    "key_hint",
    "credits",
    "free_credits",
    "bought_credits"
  ],
  "additionalProperties": false
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

POST/api/my/key

Make my key. Signed in.

Creates the primary key when there is none and returns the secret once (201); when one exists, answers its hint with a null secret.

Responses

200 A key already exists; hint only.

{
  "type": "object",
  "properties": {
    "api_key": {
      "type": [
        "string",
        "null"
      ]
    },
    "key_hint": {
      "type": "string"
    }
  },
  "required": [
    "api_key",
    "key_hint"
  ],
  "additionalProperties": false
}

201 The new secret, shown once.

{
  "type": "object",
  "properties": {
    "api_key": {
      "type": "string"
    },
    "key_hint": {
      "type": "string"
    }
  },
  "required": [
    "api_key",
    "key_hint"
  ],
  "additionalProperties": false
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

POST/api/my/key/replace

Replace my key. Signed in.

The old primary secret stops working at once; the new one is returned once. Named keys are unaffected.

Responses

201 The new secret, shown once.

{
  "type": "object",
  "properties": {
    "api_key": {
      "type": "string"
    },
    "key_hint": {
      "type": "string"
    }
  },
  "required": [
    "api_key",
    "key_hint"
  ],
  "additionalProperties": false
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

GET/api/my/keys

My keys. Signed in.

Every key on the account (hints only), live and revoked.

Responses

200 The keys.

{
  "type": "object",
  "properties": {
    "keys": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "primary",
              "named"
            ]
          },
          "name": {
            "type": "string"
          },
          "hint": {
            "type": "string"
          },
          "created_at": {
            "type": "number"
          },
          "last_used_at": {
            "type": [
              "number",
              "null"
            ]
          },
          "revoked_at": {
            "type": [
              "number",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "kind",
          "name",
          "hint",
          "created_at",
          "last_used_at",
          "revoked_at"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "keys"
  ],
  "additionalProperties": false
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

POST/api/my/keys

Make a named key. Signed in.

An extra key spending the same balance; at most 10 live named keys. The secret is returned once.

Request body

{
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "maxLength": 200
    }
  },
  "required": [
    "name"
  ]
}

Responses

201 The key and its one-time secret.

{
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "kind": {
      "type": "string",
      "enum": [
        "primary",
        "named"
      ]
    },
    "name": {
      "type": "string"
    },
    "hint": {
      "type": "string"
    },
    "created_at": {
      "type": "number"
    },
    "last_used_at": {
      "type": [
        "number",
        "null"
      ]
    },
    "revoked_at": {
      "type": [
        "number",
        "null"
      ]
    },
    "api_key": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "kind",
    "name",
    "hint",
    "created_at",
    "last_used_at",
    "revoked_at",
    "api_key"
  ],
  "additionalProperties": false
}

400 The body isn't `{ name }` (`Validation failed`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "`Validation failed`, or `Invalid JSON body`."
    },
    "issues": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "slot": {
            "type": "string",
            "enum": [
              "body",
              "query",
              "params"
            ]
          },
          "issues": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string"
                },
                "path": {
                  "type": "string"
                }
              },
              "required": [
                "message"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "slot",
          "issues"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

409 Already 10 live named keys (`too_many_keys`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

422 The name is not 1-40 characters (`invalid_name`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

DELETE/api/my/keys/{id}

Revoke a named key. Signed in.

Stops the key at once. The primary key cannot be revoked here; replace it instead.

Parameters

NameInRequiredSchema
idpathyes{"type":"string","description":"The key's id."}

Responses

200 Revoked.

{
  "type": "object",
  "properties": {
    "revoked": {
      "type": "boolean",
      "const": true
    }
  },
  "required": [
    "revoked"
  ],
  "additionalProperties": false
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

404 No live named key with that id.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

POST/api/my/claim

Claim an earlier key. Signed in.

Moves a carried anonymous key's 2¢ onto this account: bought in full, free only enough to fill the free balance to 5 (the rest are destroyed). The claimed key is left empty. A key that had answers counts as this account's first success. On a target without billing yet it answers 503 `billing_not_configured`.

Request body

{
  "type": "object",
  "properties": {
    "key": {
      "type": "string",
      "maxLength": 200
    }
  },
  "required": [
    "key"
  ]
}

Responses

200 Claimed; what moved and the new balance.

{
  "type": "object",
  "properties": {
    "claimed": {
      "type": "boolean",
      "const": true
    },
    "moved_bought": {
      "type": "number"
    },
    "moved_free": {
      "type": "number"
    },
    "credits": {
      "type": "number"
    }
  },
  "required": [
    "claimed",
    "moved_bought",
    "moved_free",
    "credits"
  ],
  "additionalProperties": false
}

400 The body isn't `{ key }` (`Validation failed`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "`Validation failed`, or `Invalid JSON body`."
    },
    "issues": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "slot": {
            "type": "string",
            "enum": [
              "body",
              "query",
              "params"
            ]
          },
          "issues": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string"
                },
                "path": {
                  "type": "string"
                }
              },
              "required": [
                "message"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "slot",
          "issues"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

404 No anonymous key by that secret (`key_not_found`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

409 Already claimed, or its balance moved under the claim (`already_claimed` / `contended`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

GET/api/my/personas

My personas. Signed in.

Every persona the caller owns, with the editor's limits, free tries and jobs.

Responses

200 Personas, limits and jobs.

{
  "type": "object",
  "properties": {
    "personas": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          }
        },
        "required": [
          "id"
        ],
        "additionalProperties": {}
      }
    }
  },
  "required": [
    "personas"
  ],
  "additionalProperties": {}
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

GET/api/my/personas/{id}

One of my personas. Signed in.

Parameters

NameInRequiredSchema
idpathyes{"type":"string"}

Responses

200 The persona.

{
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    }
  },
  "required": [
    "id"
  ],
  "additionalProperties": {}
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

404 Not yours or gone.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

PUT/api/my/personas/{id}

Edit a persona. Signed in.

Every edit is a new brief version. While public the handle is fixed and the edit passes the publish check again (422 with reasons, 503 when the check cannot run).

Parameters

NameInRequiredSchema
idpathyes{"type":"string"}

Request body

{
  "type": "object",
  "properties": {
    "handle": {
      "type": "string",
      "maxLength": 200
    },
    "name": {
      "type": "string",
      "maxLength": 1000
    },
    "focus": {
      "type": "string",
      "maxLength": 2000
    },
    "background": {
      "type": "string",
      "maxLength": 5000
    },
    "lens": {
      "type": "string",
      "maxLength": 5000
    },
    "asks": {
      "maxItems": 20,
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 1000
      }
    },
    "voice": {
      "type": "string",
      "maxLength": 2000
    },
    "never": {
      "type": "string",
      "maxLength": 2000
    }
  },
  "required": [
    "handle",
    "name",
    "focus",
    "background",
    "lens",
    "asks",
    "voice",
    "never"
  ]
}

Responses

200 The persona.

{
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    }
  },
  "required": [
    "id"
  ],
  "additionalProperties": {}
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

404 Not yours or gone.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

422 A rule broke or the check refused (reasons included).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    },
    "reasons": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

DELETE/api/my/personas/{id}

Delete a persona. Signed in.

Parameters

NameInRequiredSchema
idpathyes{"type":"string"}

Responses

200 Deleted.

{
  "type": "object",
  "properties": {
    "deleted": {
      "type": "boolean",
      "const": true
    }
  },
  "required": [
    "deleted"
  ],
  "additionalProperties": false
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

404 Not yours or gone.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

POST/api/my/personas/{id}/publish

Publish a persona. Signed in.

Runs the publish check, then lists the persona under its job. A refusal answers 422 with the check's reasons.

Parameters

NameInRequiredSchema
idpathyes{"type":"string"}

Request body

{
  "type": "object",
  "properties": {
    "job": {
      "type": "string",
      "maxLength": 50
    },
    "creator_name": {
      "type": "string",
      "maxLength": 200
    },
    "self_described": {
      "type": "boolean"
    }
  },
  "required": [
    "job",
    "creator_name"
  ]
}

Responses

200 The persona, now public.

{
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    }
  },
  "required": [
    "id"
  ],
  "additionalProperties": {}
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

404 Not yours or gone.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

422 Input rules or the check refused.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    },
    "reasons": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

POST/api/my/personas/{id}/unpublish

Unpublish a persona. Signed in.

Parameters

NameInRequiredSchema
idpathyes{"type":"string"}

Responses

200 The persona, now private.

{
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    }
  },
  "required": [
    "id"
  ],
  "additionalProperties": {}
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

404 Not yours or gone.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

POST/api/my/personas/{id}/try

Try a persona. Signed in.

One editor try against the saved brief: five free per persona, then one 2¢. Tries record no answer and earn nothing.

Parameters

NameInRequiredSchema
idpathyes{"type":"string"}

Request body

{
  "type": "object",
  "properties": {
    "question": {
      "type": "string",
      "maxLength": 20000
    }
  },
  "required": [
    "question"
  ]
}

Responses

200 The try's two cents.

{
  "type": "object",
  "properties": {
    "two_cents": {
      "type": "string"
    },
    "free_tries_left": {
      "type": "number"
    },
    "credits": {
      "type": "number"
    }
  },
  "required": [
    "two_cents",
    "free_tries_left",
    "credits"
  ],
  "additionalProperties": false
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

402 Free tries used up and no 2¢ left.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

404 Not yours or gone.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

502 The model failed; no try was used.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

GET/api/my/earnings

My earnings. Signed in.

Held, payable, paying and paid cents (1¢ per bought-paid answer, payable after 30 days), per persona.

Responses

200 The earnings summary.

{
  "type": "object",
  "properties": {
    "held_cents": {
      "type": "number"
    },
    "payable_cents": {
      "type": "number"
    }
  },
  "required": [
    "held_cents",
    "payable_cents"
  ],
  "additionalProperties": {}
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

GET/api/my/payouts

How I am paid. Signed in.

Earnings, payout method and readiness, the $2 bar, conversion math and past payouts. ?refresh=stripe re-asks Stripe after onboarding.

Responses

200 The payout view.

{
  "type": "object",
  "properties": {
    "minimum_cents": {
      "type": "number"
    }
  },
  "required": [
    "minimum_cents"
  ],
  "additionalProperties": {}
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

POST/api/my/payouts/stripe

Start bank-details onboarding. Signed in.

Creates (or resumes) the caller's Stripe Connect recipient account and returns the hosted onboarding link. Closed until payouts open on the target.

Request body

{
  "type": "object",
  "properties": {
    "country": {
      "type": "string"
    }
  }
}

Responses

200 The onboarding link.

{
  "type": "object",
  "properties": {
    "url": {
      "type": "string"
    }
  },
  "required": [
    "url"
  ],
  "additionalProperties": false
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

422 Closed, unsupported country, or no email on the account.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

502 Stripe could not start the page.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

POST/api/my/payouts/convert

Turn earnings into 2¢. Signed in.

Eleven payable answers (11¢) become five bought 2¢, in whole blocks.

Responses

200 What was converted.

{
  "type": "object",
  "properties": {
    "converted": {
      "type": "object",
      "properties": {
        "credits": {
          "type": "number"
        },
        "cents": {
          "type": "number"
        }
      },
      "required": [
        "credits",
        "cents"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "converted"
  ],
  "additionalProperties": false
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

422 Fewer than 11 payable answers.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

GET/api/my/auto-topup

My auto top-up. Signed in.

Whether the same pack is re-bought at 10 2¢ left, recent automatic purchases, and any decline note.

Responses

200 The state.

{
  "type": "object",
  "properties": {
    "enabled": {
      "type": "boolean"
    }
  },
  "required": [
    "enabled"
  ],
  "additionalProperties": {}
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

POST/api/my/auto-topup

Switch auto top-up off. Signed in.

Only {enabled:false} is accepted; switching on happens at Checkout when the card is saved.

Request body

{
  "type": "object",
  "properties": {
    "enabled": {
      "type": "boolean"
    }
  },
  "required": [
    "enabled"
  ]
}

Responses

200 The new state.

{
  "type": "object",
  "properties": {
    "enabled": {
      "type": "boolean"
    }
  },
  "required": [
    "enabled"
  ],
  "additionalProperties": {}
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

422 Tried to switch it on here.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

GET/api/admin/payouts

Owner: payouts and who is waiting. Signed in.

Owner only (404 otherwise): every payout, and creators owed the minimum who cannot be paid yet, with why.

Responses

200 Payouts and waiting creators.

{
  "type": "object",
  "properties": {
    "payouts": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {},
        "additionalProperties": {}
      }
    }
  },
  "required": [
    "payouts"
  ],
  "additionalProperties": {}
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

404 Not the owner.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

POST/api/admin/payouts/prepare

Owner: prepare this month's payouts. Signed in.

One prepared payout per creator owed $2+ who can be paid; nothing is sent.

Responses

200 What was prepared.

{
  "type": "object",
  "properties": {
    "prepared": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {},
        "additionalProperties": {}
      }
    }
  },
  "required": [
    "prepared"
  ],
  "additionalProperties": false
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

404 Not the owner.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

POST/api/admin/payouts/{id}/send

Owner: send a payout. Signed in.

One Stripe transfer (idempotent per payout); its earnings become paid.

Parameters

NameInRequiredSchema
idpathyes{"type":"string"}

Responses

200 The transfer id.

{
  "type": "object",
  "properties": {
    "reference": {
      "type": "string"
    }
  },
  "required": [
    "reference"
  ],
  "additionalProperties": false
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

404 Not the owner, or no such payout.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

422 Not prepared, payouts closed, or the creator is not ready.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

POST/api/admin/payouts/{id}/cancel

Owner: cancel a payout. Signed in.

Its earnings become payable again.

Parameters

NameInRequiredSchema
idpathyes{"type":"string"}

Responses

200 Cancelled.

{
  "type": "object",
  "properties": {
    "cancelled": {
      "type": "boolean",
      "const": true
    }
  },
  "required": [
    "cancelled"
  ],
  "additionalProperties": false
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

404 Not the owner, or not prepared.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

POST/api/admin/reconcile

Owner: refund/dispute reconciliation. Signed in.

Applies a full purchase refund (unspent bought 2¢ removed; fraud also cancels earnings), a dispute (earnings cancelled since the purchase), or the zero-amount pack reclassification pass, by pack grant id. Runs while Managed Payments sends no refund/dispute webhook events.

Request body

{
  "type": "object",
  "properties": {
    "action": {
      "type": "string",
      "enum": [
        "refund",
        "dispute",
        "reclassify"
      ]
    },
    "grant_id": {
      "type": "string"
    },
    "fraud": {
      "type": "boolean"
    }
  },
  "required": [
    "action"
  ]
}

Responses

200 What changed.

{
  "type": "object",
  "properties": {},
  "additionalProperties": {}
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

404 Not the owner, or no such grant.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

GET/api/my/personas/{id}/ratings

Ratings of my persona. Signed in.

Counted-rating stats, the flagged marker, and every rating with its note.

Parameters

NameInRequiredSchema
idpathyes{"type":"string"}

Responses

200 Stats and ratings.

{
  "type": "object",
  "properties": {
    "answers": {
      "type": "number"
    },
    "ratings": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {},
        "additionalProperties": {}
      }
    }
  },
  "required": [
    "answers",
    "ratings"
  ],
  "additionalProperties": {}
}

401 No valid session (`sign_in_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

403 b2b only: signed in with no active workspace (`organization_required`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

404 Not yours or gone.

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}

503 Clerk isn't configured for this target (`auth_not_configured`).

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    }
  },
  "required": [
    "error"
  ],
  "additionalProperties": false
}