# Matchbit Read these instructions before onboarding or taking a requested action. Use this origin's API. Send JSON with Content-Type: application/json. Use an API key in the x-api-key header for all authenticated entries and matches requests. Never use browser cookies, an existing browser session, or session cookies for these requests. The only use of a temporary email-verification session is to mint an API key and sign out, as described below. Keep codes, cookies, keys, and submission IDs private; never include them in chat replies, published entries, or logs. ## First time 1. Use authorized context to suggest searches (what the user wants) and listings (what they offer). If context is missing, ask one focused question. Show the exact text, omit identifying details, and publish only what the user approves. Explain that people they match with can see approved entries. 2. Ask for their email. POST /api/entries without credentials: {"email":"person@example.com","entries":[{"kind":"search","content":"A neighbor to trade vegetable seedlings with"}]}. A 202 sends a code and returns a private submissionId. The entries are pending, not live. Pending submissions expire after 15 minutes. 3. Explain that they need to verify their email and ask for the six-digit code. If the user asks you to retrieve it and an authorized email connection is available, use that connection. Codes expire in five minutes. 4. Complete the required API key setup below. Email verification alone does not publish the pending entries. 5. Using only the new API key in x-api-key, POST /api/entries/confirm with {"submissionId":"ID"}. A 201 means the approved entries are live. After an uncertain response, GET /api/entries with the key to check before resubmitting. ## Required API key setup after email verification 1. POST /api/auth/sign-in/email-otp without existing credentials: {"email":"person@example.com","otp":"CODE"}. This verifies the email and signs the user in, creating their account if needed. Hold the returned session cookies privately and temporarily for steps 2 and 3 only. Do not use or persist the user's browser cookies. 2. Immediately POST /api/auth/api-key/create with {"name":"My agent"}, authenticated only with those temporary session cookies. Always mint a key after successful email verification, even if you cannot save it for later. Read the secret from the response's key field. The key expires in 90 days. Keep it privately for the current task; optionally save it through the host's secure credential storage if supported. Never persist session cookies or write credentials into project files. 3. POST /api/auth/sign-out using the temporary session cookies, without the API key. Confirm sign-out succeeds, then discard the cookies. Attempt sign-out and discard the cookies even if key creation or storage fails. If key creation or sign-out fails, stop and report that setup could not be completed; do not fall back to session-authenticated API calls. 4. After sign-out, use only the API key in x-api-key for all subsequent authenticated API calls. Do not send session cookies alongside it. ## Returning Use a privately saved, valid API key in x-api-key. No new email code is needed while the key is valid. If no key is available, or the API rejects it as invalid, expired, or revoked, ask for their email and POST /api/auth/email-otp/send-verification-otp without credentials: {"email":"person@example.com","type":"sign-in"}. Ask for the code, or retrieve it through an authorized email connection at the user's request. Complete the required API key setup above before taking the requested action. Never reuse a session as a substitute for a key. - See matches: GET /api/matches. Report only returned matches. Automatic matching and match emails are unavailable. - Post approved entries: POST /api/entries with an array of {"kind":"search" or "listing","content":"..."} objects. Confirm a 201. - Remove an entry: GET /api/entries to find its ID, then DELETE /api/entries/ID. See /docs for request and response examples.