{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["tabs","tab","admonition","visibility"]},"type":"markdown"},"seo":{"title":"Quickstart","description":"Reference, guides, and webhooks for the Aiwyn API: clients, contacts, engagements, projects, billing, payments, time, and files.","llmstxt":{"title":"Aiwyn API","description":"Aiwyn Product API documentation. Start with reference/quickstart.md; the API reference lists every endpoint, its required role, its request and response schemas, and the webhook payload."}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"quickstart","__idx":0},"children":["Quickstart"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Make your first Product API request in three steps: get credentials, exchange your API key for a"," ","bearer token, and call an endpoint. The examples use Sandbox; see"," ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/reference/base-urls"},"children":["Base URLs & environments"]}," for Staging and Production."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"1-get-your-credentials","__idx":1},"children":["1. Get your credentials"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Ask ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"mailto:api-support@aiwyn.ai"},"children":["api-support@aiwyn.ai"]}," for:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Credential"},"children":["Credential"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"What it is"},"children":["What it is"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Needed on"},"children":["Needed on"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["JWT API key"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Identifies your integration and your firm, for example ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["dev:eyJ..."]},". Long-lived; store it like a password."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Every environment (each has its own key)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Cloudflare Access client ID and secret"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Get requests past Cloudflare to the API."]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Sandbox and Staging only"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The roles provisioned for the key decide which endpoints it can call; see"," ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/reference/authorization"},"children":["Authentication & authorization"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Keep all of them server-side. The examples read them from environment variables:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"export AIWYN_BASE_URL=https://api.sandbox.aiwyn.app\nexport AIWYN_API_KEY='<your-jwt-api-key>'\nexport CF_ACCESS_CLIENT_ID='<cf-access-client-id>'\nexport CF_ACCESS_CLIENT_SECRET='<cf-access-client-secret>'\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"2-exchange-your-api-key-for-a-bearer-token","__idx":2},"children":["2. Exchange your API key for a bearer token"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /v1/auth/token"]}," takes the API key in the body and returns a bearer token that lasts up to an"," ","hour. The exchange can hand back a token it issued earlier, with only minutes left, so ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["request a new"," ","token whenever a call answers ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["401"]}]}," rather than refreshing on a timer."]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"cURL","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl --request POST \"$AIWYN_BASE_URL/v1/auth/token\" \\\n  --header \"CF-Access-Client-Id: $CF_ACCESS_CLIENT_ID\" \\\n  --header \"CF-Access-Client-Secret: $CF_ACCESS_CLIENT_SECRET\" \\\n  --header 'Content-Type: application/json' \\\n  --data \"{ \\\"jwtApiKey\\\": \\\"$AIWYN_API_KEY\\\" }\"\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"import os\nimport requests\n\nbase_url = os.environ[\"AIWYN_BASE_URL\"]\n# Sandbox and Staging only; on Production leave the two variables unset.\ncloudflare = (\n    {\n        \"CF-Access-Client-Id\": os.environ[\"CF_ACCESS_CLIENT_ID\"],\n        \"CF-Access-Client-Secret\": os.environ[\"CF_ACCESS_CLIENT_SECRET\"],\n    }\n    if os.environ.get(\"CF_ACCESS_CLIENT_ID\")\n    else {}\n)\n\nresponse = requests.post(\n    f\"{base_url}/v1/auth/token\",\n    headers=cloudflare,\n    json={\"jwtApiKey\": os.environ[\"AIWYN_API_KEY\"]},\n    timeout=30,\n)\nresponse.raise_for_status()\ntoken = response.json()[\"token\"]\n","lang":"python"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"JavaScript","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const baseUrl = process.env.AIWYN_BASE_URL;\n// Sandbox and Staging only; on Production leave the two variables unset.\nconst cloudflare = process.env.CF_ACCESS_CLIENT_ID\n  ? {\n      'CF-Access-Client-Id': process.env.CF_ACCESS_CLIENT_ID,\n      'CF-Access-Client-Secret': process.env.CF_ACCESS_CLIENT_SECRET,\n    }\n  : {};\n\nconst response = await fetch(`${baseUrl}/v1/auth/token`, {\n  method: 'POST',\n  headers: { ...cloudflare, 'Content-Type': 'application/json' },\n  body: JSON.stringify({ jwtApiKey: process.env.AIWYN_API_KEY }),\n});\nif (!response.ok) throw new Error(`Token exchange failed: ${response.status}`);\nconst { token } = await response.json();\n","lang":"javascript"},"children":[]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The response is the token alone:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{ \"token\": \"eyJhbGciOiJIUzUxMiJ9...\" }\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["401"]}," with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\"code\": \"UNAUTHORIZED\""]}," means the key is wrong, deactivated, or from another"," ","environment. A response that is not JSON comes from Cloudflare: the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CF-Access-*"]}," headers are missing or wrong."]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"Production"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Production (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://api.aiwyn.ai"]},") does not use Cloudflare Access: leave out the two ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CF-Access-*"]}," ","headers there. The Python and JavaScript examples send them only when ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["CF_ACCESS_CLIENT_ID"]}," is set, so"," ","unset both variables when you point ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["AIWYN_BASE_URL"]}," at Production."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"3-make-your-first-request","__idx":3},"children":["3. Make your first request"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["List the first five clients of your firm. Send the token in the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Authorization"]}," header (plus the"," ","Cloudflare headers on Sandbox and Staging):"]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"cURL","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl --request POST \"$AIWYN_BASE_URL/gql/v1/clients\" \\\n  --header \"CF-Access-Client-Id: $CF_ACCESS_CLIENT_ID\" \\\n  --header \"CF-Access-Client-Secret: $CF_ACCESS_CLIENT_SECRET\" \\\n  --header \"Authorization: Bearer $TOKEN\" \\\n  --header 'Content-Type: application/json' \\\n  --data '{ \"pageSize\": 5, \"page\": 0 }'\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Python","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"response = requests.post(\n    f\"{base_url}/gql/v1/clients\",\n    headers={**cloudflare, \"Authorization\": f\"Bearer {token}\"},\n    json={\"pageSize\": 5, \"page\": 0},\n    timeout=30,\n)\nresponse.raise_for_status()\nclients = response.json()[\"clients\"]\n","lang":"python"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"JavaScript","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const clientsResponse = await fetch(`${baseUrl}/gql/v1/clients`, {\n  method: 'POST',\n  headers: { ...cloudflare, Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },\n  body: JSON.stringify({ pageSize: 5, page: 0 }),\n});\nif (!clientsResponse.ok) throw new Error(`Listing clients failed: ${clientsResponse.status}`);\nconst { clients, total } = await clientsResponse.json();\n","lang":"javascript"},"children":[]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The response holds the page of clients and the total number of clients in your firm:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n  \"clients\": [\n    { \"id\": 122, \"pmsRef\": \"1155\", \"clientRef\": \"41664\", \"name\": \"Acme Bread Co.\", \"active\": true }\n  ],\n  \"total\": { \"aggregate\": { \"count\": 13697 } }\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For the cURL example, set ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TOKEN"]}," to the token from step 2 first (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["export TOKEN='<token>'"]},")."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"next-steps","__idx":4},"children":["Next steps"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/reference/pagination"},"children":["Pagination"]},": read the next page by advancing ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["page"]}," by ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["pageSize"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/reference/base-urls#path-prefixes"},"children":["Base URLs & environments"]},": what the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/gql/v1"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/api/v1"]}," and"," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/v1/auth"]}," prefixes mean."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/reference/errors"},"children":["Errors"]},": the error bodies and what to retry."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Webhooks"]}," in the API reference: receive signed events instead of polling, after creating a"," ","subscription with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /api/v1/event-subscriptions"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The API reference's ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Try it"]}," panel sends any request from your browser once you enter your token"," ","and, for Sandbox or Staging, the Cloudflare credentials."]}]}]},"headings":[{"value":"Quickstart","id":"quickstart","depth":1},{"value":"1. Get your credentials","id":"1-get-your-credentials","depth":2},{"value":"2. Exchange your API key for a bearer token","id":"2-exchange-your-api-key-for-a-bearer-token","depth":2},{"value":"3. Make your first request","id":"3-make-your-first-request","depth":2},{"value":"Next steps","id":"next-steps","depth":2}],"frontmatter":{"seo":{"title":"Quickstart"}},"lastModified":"2026-11-23T07:25:47.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/reference/quickstart","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}