{"openapi":"3.1.0","info":{"title":"Munja API","version":"0.1.0","summary":"Show approved partner offers after checkout, record the yes, and receive signed webhooks.","description":"Munja shows 2 or 3 approved partner offers on a business's confirmation page, confirmation email or exit popup. A host (the business) calls `POST /v1/offers` with its publishable key, renders the offers, and calls the accept endpoint when the customer says yes. Partners pay per yes. This spec lists only endpoints that exist today. Test-mode keys (`pk_test_`, `sk_test_`) touch test data only.","contact":{"name":"Munja support","email":"support@getmunja.com"}},"servers":[{"url":"https://getmunja.com","description":"Production host. Use test-mode keys while building."}],"tags":[{"name":"Offers","description":"Browser-safe endpoints that use a publishable key (`pk_test_...`)."},{"name":"Agents","description":"Accepting an offer for a customer who consented, from an AI shopping agent."},{"name":"Leads","description":"Server endpoints that use a secret key (`sk_test_...`)."},{"name":"Webhook endpoints","description":"Where Munja sends signed events."},{"name":"Events","description":"Event history."},{"name":"Conversions","description":"Partner postbacks for what happened after a yes."},{"name":"Zapier host channel","description":"Test-mode host endpoints used by the private Zapier app."}],"paths":{"/v1/offers":{"post":{"tags":["Offers"],"operationId":"decideOffers","summary":"Get the offers for one order","description":"Returns the offers to show for one order at one moment, with an impression token on each offer. The same order and shop returns the same offers (`replayed: true`) with no new impression. `customer.phone` is accepted and discarded. If an order signature is sent and does not match, the call fails with `invalid_signature`. Accounts that require signed orders also fail with `signature_required` when it is missing.","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DecideRequest"}}}},"responses":{"200":{"description":"The offers, possibly an empty list. Check `empty_reason` when it is empty.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OfferList"}}}},"400":{"description":"A parameter is invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unknown publishable key, bad signature or signature required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"tags":["Offers"],"operationId":"decideOffersGet","summary":"Get the offers for one order (query string form)","description":"Same as POST, with the fields as query parameters. Context fields go in `context[name]=value`, and `zip` is a shortcut for `context[zip]`.","parameters":[{"name":"key","in":"query","required":true,"schema":{"type":"string","pattern":"^pk_(test|live)_[A-Za-z0-9]{8,64}$"}},{"name":"order_id","in":"query","schema":{"type":"string","maxLength":120}},{"name":"signature","in":"query","schema":{"type":"string","maxLength":128}},{"name":"moment","in":"query","schema":{"type":"string","maxLength":60}},{"name":"surface","in":"query","schema":{"$ref":"#/components/schemas/Surface"}},{"name":"email","in":"query","schema":{"type":"string","maxLength":254}},{"name":"name","in":"query","schema":{"type":"string","maxLength":120}},{"name":"zip","in":"query","schema":{"type":"string"}},{"name":"page_url","in":"query","schema":{"type":"string","maxLength":500}}],"responses":{"200":{"description":"The offers.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OfferList"}}}},"400":{"description":"A parameter is invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unknown publishable key, bad signature or signature required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/offers/{token}/view":{"post":{"tags":["Offers"],"operationId":"viewOffer","summary":"Count an offer as seen","description":"Only needed for the Featured layout, where offers after the first count as shown when the customer actually sees them.","parameters":[{"name":"token","in":"path","required":true,"description":"The impression token from the `impression` field of an offer.","schema":{"type":"string"}}],"security":[],"responses":{"200":{"description":"Counted.","content":{"application/json":{"schema":{"type":"object","properties":{"object":{"const":"view"},"shown":{"type":"boolean"}}}}}},"429":{"description":"Rate limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/offers/{token}/accept":{"post":{"tags":["Offers"],"operationId":"acceptOffer","summary":"Record the customer's yes","description":"Call when the customer presses the offer button. Creates the lead and the consent record, charges the partner and delivers the signed webhooks. Safe to retry: the same lead comes back. Offers with `yes_tier` of `call` or `quote` need `phone`, and `quote` also needs `zip` and `details`, plus `consent: true` only when the customer ticked the call-consent box.","parameters":[{"name":"token","in":"path","required":true,"description":"The impression token from the `impression` field of an offer.","schema":{"type":"string"}}],"security":[],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string","format":"email"},"name":{"type":"string"},"phone":{"type":"string"},"zip":{"type":"string"},"details":{"type":"string"},"consent":{"type":"boolean"}}}}}},"responses":{"201":{"description":"Accepted.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Acceptance"}}}},"400":{"description":"Invalid input, for example phone_invalid, phone_required, zip_invalid, details_invalid or consent_required. Nothing is shared or charged.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such offer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/offers/{token}/dismiss":{"post":{"tags":["Offers"],"operationId":"dismissOffer","summary":"Customer said no thanks","parameters":[{"name":"token","in":"path","required":true,"description":"The impression token from the `impression` field of an offer.","schema":{"type":"string"}}],"security":[],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"all":{"type":"boolean","description":"Dismiss the whole unit."}}}}}},"responses":{"200":{"description":"Dismissed.","content":{"application/json":{"schema":{"type":"object","properties":{"object":{"const":"dismissal"},"dismissed":{"type":"boolean"}}}}}},"429":{"description":"Rate limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/offers/{token}/report":{"post":{"tags":["Offers"],"operationId":"reportOffer","summary":"Report an offer or opt out of a partner","description":"Nothing is charged.","parameters":[{"name":"token","in":"path","required":true,"description":"The impression token from the `impression` field of an offer.","schema":{"type":"string"}}],"security":[],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"kind":{"enum":["complaint","opt_out"]},"reason":{"type":"string"}}}}}},"responses":{"200":{"description":"Recorded.","content":{"application/json":{"schema":{"type":"object","properties":{"object":{"const":"offer_report"},"kind":{"enum":["complaint","opt_out"]}}}}}},"404":{"description":"No such offer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/offers/{token}/continue":{"get":{"tags":["Offers"],"operationId":"continueToPartner","summary":"Send the customer on to the partner","description":"Open this URL in the customer's browser after a yes. It counts the first visit (never billed) and redirects to the partner's page. It returns 404 before a yes.","parameters":[{"name":"token","in":"path","required":true,"description":"The impression token from the `impression` field of an offer.","schema":{"type":"string"}}],"security":[],"responses":{"302":{"description":"Redirect to the partner's landing page."},"404":{"description":"Not available. Nothing was shared."},"429":{"description":"Rate limited."}}}},"/v1/agent/accept":{"post":{"tags":["Agents"],"operationId":"agentAccept","summary":"Accept an offer for a customer who consented","description":"For an AI shopping agent. Needs an `offer_id` and `key` from the offer catalog on the confirmation page, and an attestation of the customer's explicit consent. See also /openapi-agent.json.","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AgentAcceptRequest"}}}},"responses":{"200":{"description":"Duplicate: this customer already said yes to this partner in the last 30 days. Not charged.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Acceptance"}}}},"201":{"description":"Accepted.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Acceptance"}}}},"400":{"description":"A field is missing or invalid, or consent is missing or stale.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"The host or partner does not accept agent opt-ins.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The offer is not available for this order.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/leads":{"post":{"tags":["Leads"],"operationId":"createLead","summary":"Record a customer's yes from your server","description":"Merchant secret key. For hosts that render offers themselves and record the yes server side. Same email and partner within 30 days is recorded as `duplicate` and not charged. Send the exact disclosure text the customer saw.","security":[{"secretKey":[]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Safe retries. The response is kept for 24 hours. Reusing a key with a different body returns 422.","schema":{"type":"string","maxLength":255}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadCreate"}}}},"responses":{"201":{"description":"Recorded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Lead"}}}},"400":{"description":"Invalid input, or the email domain cannot receive mail.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid secret key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a merchant key, or offers are turned off.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such live offer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"tags":["Leads"],"operationId":"listLeads","summary":"List the latest 100 leads","description":"Contact details are never listed. Partners receive them in the signed `lead.created` webhook. Use `limit` (1 to 100, default 100) and `starting_after` (an id from the previous page).","security":[{"secretKey":[]}],"parameters":[{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100}},{"name":"starting_after","in":"query","schema":{"type":"string"},"description":"Id of the last object on the previous page."}],"responses":{"200":{"description":"A list.","content":{"application/json":{"schema":{"type":"object","required":["object","data","has_more"],"properties":{"object":{"const":"list"},"data":{"type":"array","items":{"$ref":"#/components/schemas/LeadSummary"}},"has_more":{"type":"boolean"}}}}}},"401":{"description":"Missing or invalid secret key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/webhook_endpoints":{"get":{"tags":["Webhook endpoints"],"operationId":"listWebhookEndpoints","summary":"List webhook endpoints","security":[{"secretKey":[]}],"responses":{"200":{"description":"A list.","content":{"application/json":{"schema":{"type":"object","required":["object","data","has_more"],"properties":{"object":{"const":"list"},"data":{"type":"array","items":{"$ref":"#/components/schemas/WebhookEndpoint"}},"has_more":{"type":"boolean"}}}}}},"401":{"description":"Missing or invalid secret key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Webhook endpoints"],"operationId":"createWebhookEndpoint","summary":"Create a webhook endpoint","description":"The signing secret (`whsec_...`) is returned once, in this response. The URL must be https, unless it is a Munja sandbox inbox. If you omit events, a host endpoint listens for `offer.accepted` and a partner endpoint listens for `lead.created`.","security":[{"secretKey":[]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Safe retries. The response is kept for 24 hours. Reusing a key with a different body returns 422.","schema":{"type":"string","maxLength":255}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["url"],"properties":{"url":{"type":"string","format":"uri","maxLength":2048},"description":{"type":"string","maxLength":200},"events":{"type":"array","items":{"$ref":"#/components/schemas/EventType"}}}}}}},"responses":{"201":{"description":"Created. Store the secret now.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEndpointCreated"}}}},"400":{"description":"The URL is invalid or not https.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid secret key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/events":{"get":{"tags":["Events"],"operationId":"listEvents","summary":"List events","description":"Newest first. Use `limit` and `starting_after` to page.","security":[{"secretKey":[]}],"parameters":[{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100}},{"name":"starting_after","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"A list.","content":{"application/json":{"schema":{"type":"object","required":["object","data","has_more"],"properties":{"object":{"const":"list"},"data":{"type":"array","items":{"$ref":"#/components/schemas/EventSummary"}},"has_more":{"type":"boolean"}}}}}},"401":{"description":"Missing or invalid secret key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/refund_requests":{"post":{"tags":["Leads"],"operationId":"createRefundRequest","summary":"Ask for a refund on a lead","description":"Partner secret key. One request per lead, within 14 days.","security":[{"secretKey":[]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Safe retries. The response is kept for 24 hours. Reusing a key with a different body returns 422.","schema":{"type":"string","maxLength":255}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["lead","reason"],"properties":{"lead":{"type":"string"},"reason":{"enum":["duplicate","wrong_contact","out_of_area","test","fraud","other"]},"note":{"type":"string","maxLength":1000}}}}}},"responses":{"201":{"description":"Requested.","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"object":{"const":"refund_request"},"status":{"const":"requested"}}}}}},"400":{"description":"Invalid reason, or the lead cannot be refunded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such lead.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/conversions":{"post":{"tags":["Conversions"],"operationId":"createConversion","summary":"Report a conversion for a lead","description":"Partner secret key. Send `mj_click_id` (from the lead.created webhook) or `lead`. Idempotent on `external_id`.","security":[{"secretKey":[]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Safe retries. The response is kept for 24 hours. Reusing a key with a different body returns 422.","schema":{"type":"string","maxLength":255}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["external_id"],"properties":{"mj_click_id":{"type":"string","maxLength":64},"lead":{"type":"string","maxLength":64},"type":{"enum":["quote","application","booking","purchase","custom"],"default":"purchase"},"external_id":{"type":"string","maxLength":200},"value":{"type":"integer","description":"Cents."},"currency":{"type":"string","maxLength":3,"default":"usd"},"occurred_at":{"description":"Unix seconds or an ISO 8601 time.","oneOf":[{"type":"integer"},{"type":"string","format":"date-time"}]}}}}}},"responses":{"200":{"description":"Already recorded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Conversion"}}}},"201":{"description":"Recorded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Conversion"}}}},"403":{"description":"Not a partner key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No matching lead.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/businesses":{"get":{"tags":["Agents"],"operationId":"searchLocalBusinesses","summary":"Find local businesses","description":"Secret key. Returns unclaimed listings and hosts who turned on assistant discovery. An unclaimed listing includes a public phone and website, is marked unclaimed, and is not bookable. No offer, payment, or partner placement is created. A customer's name, email, or phone is rejected.","security":[{"secretKey":[]}],"parameters":[{"name":"category","in":"query","required":true,"schema":{"type":"string","maxLength":40},"description":"Trade: plumber, hvac, cleaner, or mover."},{"name":"zip","in":"query","schema":{"type":"string"}},{"name":"area","in":"query","schema":{"type":"string","maxLength":80}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":20}}],"responses":{"200":{"description":"Matches.","content":{"application/json":{"schema":{"type":"object","required":["object","data","has_more"],"properties":{"object":{"const":"list"},"has_more":{"type":"boolean"},"data":{"type":"array","items":{"type":"object","required":["id","name","category","phone","website","claimed","unclaimed","bookable","details"],"properties":{"id":{"type":"string"},"object":{"const":"local_business"},"name":{"type":"string"},"category":{"type":"string"},"service_area":{"type":"string"},"zip":{"type":["string","null"]},"phone":{"type":["string","null"]},"website":{"type":["string","null"]},"claimed":{"type":"boolean"},"unclaimed":{"type":"boolean"},"bookable":{"const":false},"source_attribution":{"type":["string","null"]},"details":{"type":"object","description":"Each field has value, source (public_record, website, owner, or munja_bookings), and updated_at. Reviews are only from kept or seated Munja bookings. An owner-entered rating is labeled as reported by the owner. Google and Yelp profiles are links only.","properties":{"license":{"type":["object","null"]},"years_in_business":{"type":["object","null"]},"hours":{"type":["object","null"]},"services":{"type":["object","null"]},"service_area":{"type":["object","null"]},"emergency_same_day":{"type":["object","null"]},"price_range":{"type":["object","null"]},"payment_methods":{"type":["object","null"]},"languages":{"type":["object","null"]},"insurance":{"type":["object","null"]},"photos":{"type":["object","null"]},"response_time_minutes":{"type":["object","null"]},"external_profiles":{"type":["object","null"]},"reviews":{"type":"array","items":{"type":"object"}}}}}}}}}}}},"400":{"description":"Missing trade, or a customer field was sent.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid secret key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/businesses/{id}/book":{"post":{"tags":["Agents"],"operationId":"requestLocalBooking","summary":"Ask to book a local business","description":"With AI lead billing off, an unclaimed listing records demand and returns unclaimed_not_bookable, and a claimed business is not booked. With AI_LEAD_BILLING_ENABLED=true, a claimed business that turned on Receive AI requests returns a request id and status. The key cannot set the price, mark the job kept, or consent for the customer. An unclaimed listing is still not booked or charged.","security":[{"secretKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"Safe retries. The response is kept for 24 hours. Reusing a key with a different body returns 422.","schema":{"type":"string","maxLength":255}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"category":{"type":"string"},"zip":{"type":"string"},"area":{"type":"string","maxLength":80}}}}}},"responses":{"201":{"description":"Request opened.","content":{"application/json":{"schema":{"type":"object","required":["id","status","claimed"],"properties":{"object":{"const":"ai_lead_request"},"id":{"type":"string"},"status":{"type":"string"},"category":{"type":"string"},"area":{"type":"string"},"price_rule":{"type":"string"},"amount_cents":{"type":"integer"},"verified_amount_cents":{"type":["integer","null"]},"charge_status":{"type":"string"},"claimed":{"const":true}}}}}},"400":{"description":"A customer field was sent, or the assistant tried to consent for the customer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such listing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Unclaimed listings are not bookable (unclaimed_not_bookable). A claimed business that has not opted in returns booking_not_offered. An agent cannot set the price (agent_cannot_set_price) or mark kept (agent_cannot_mark_kept).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/ai_requests/{id}":{"get":{"tags":["Agents"],"operationId":"getAiLeadRequest","summary":"Read an AI request","description":"Status for the platform key that opened the request. Does not include customer contact details.","security":[{"secretKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The request.","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"status":{"type":"string"},"amount_cents":{"type":"integer"},"charge_status":{"type":"string"},"claimed":{"const":true}}}}}},"404":{"description":"No such request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/ai_requests/{id}/report":{"post":{"tags":["Agents"],"operationId":"reportAiLeadRequest","summary":"Report what the assistant observed","description":"Stores kept, seated, or no_show as a report. It does not mark the job kept, set a price, or charge anyone.","security":[{"secretKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"Idempotency-Key","in":"header","required":false,"description":"Safe retries. The response is kept for 24 hours. Reusing a key with a different body returns 422.","schema":{"type":"string","maxLength":255}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["outcome"],"properties":{"outcome":{"enum":["kept","seated","no_show"]}}}}}},"responses":{"200":{"description":"Report stored. Status is unchanged unless the business or the customer already confirmed.","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"status":{"type":"string"}}}}}},"403":{"description":"The key tried to set a price or mark the job kept.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/host/me":{"get":{"tags":["Zapier host channel"],"operationId":"hostMe","summary":"Check a test secret key","description":"Returns the host name and whether follow-up email is on. Test-mode keys only.","security":[{"secretKey":[]}],"responses":{"200":{"description":"The host.","content":{"application/json":{"schema":{"type":"object","properties":{"object":{"const":"host"},"id":{"type":"string"},"name":{"type":"string"},"type":{"type":"string"},"livemode":{"const":false},"follow_up_enabled":{"type":"boolean"},"delay_minutes":{"type":"integer"}}}}}},"401":{"description":"Missing or invalid secret key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"The host channel is switched off on this server (host_api_disabled).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/host/yeses":{"get":{"tags":["Zapier host channel"],"operationId":"hostYeses","summary":"List new yeses (ids only)","description":"The latest 100 test-mode yeses. No customer contact details. Test-mode keys only.","security":[{"secretKey":[]}],"responses":{"200":{"description":"A list.","content":{"application/json":{"schema":{"type":"object","required":["object","data","has_more"],"properties":{"object":{"const":"list"},"data":{"type":"array","items":{"$ref":"#/components/schemas/HostYes"}},"has_more":{"type":"boolean"}}}}}},"401":{"description":"Missing or invalid secret key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"The host channel is switched off on this server (host_api_disabled).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/leads/{id}":{"get":{"tags":["Leads"],"operationId":"getLead","summary":"Get one yes","description":"No customer contact. `mj_id` is the attribution id.","security":[{"secretKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The yes.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadSummary"}}}},"404":{"description":"No such lead.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/events/{id}":{"get":{"tags":["Events"],"operationId":"getEvent","summary":"Get one event","description":"Merchant events never include a name, email, phone or ZIP.","security":[{"secretKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The event.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Event"}}}},"404":{"description":"No such event.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/offers_catalog":{"get":{"tags":["Offers"],"operationId":"listOfferCatalog","summary":"List configured offers","description":"Partner keys list their offers. Host keys list offers placed on their account. A yes still charges the partner `price_cents` through the normal billing path.","security":[{"secretKey":[]}],"parameters":[{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100}},{"name":"starting_after","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"A list.","content":{"application/json":{"schema":{"type":"object","required":["object","data","has_more"],"properties":{"object":{"const":"list"},"data":{"type":"array","items":{"$ref":"#/components/schemas/CatalogItem"}},"has_more":{"type":"boolean"}}}}}},"401":{"description":"Missing or invalid secret key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/partner_offers":{"get":{"tags":["Offers"],"operationId":"listPartnerOffers","summary":"List a partner's offers","security":[{"secretKey":[]}],"responses":{"200":{"description":"A list.","content":{"application/json":{"schema":{"type":"object","required":["object","data","has_more"],"properties":{"object":{"const":"list"},"data":{"type":"array","items":{"$ref":"#/components/schemas/PartnerOffer"}},"has_more":{"type":"boolean"}}}}}},"403":{"description":"Not a partner key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Offers"],"operationId":"createPartnerOffer","summary":"Create a partner offer","description":"Writes the offer. `price_cents` is what a later yes charges. The host share is not a parameter. Sandbox offers in test mode can be shown at once. Other offers stay in review. Live mode requires a person to approve the account.","security":[{"secretKey":[]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Safe retries. The response is kept for 24 hours. Reusing a key with a different body returns 422.","schema":{"type":"string","maxLength":255}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartnerOfferWrite"}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartnerOffer"}}}},"400":{"description":"Invalid copy or price.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a partner key, or live mode is not approved.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/partner_offers/{id}":{"get":{"tags":["Offers"],"operationId":"getPartnerOffer","summary":"Get one partner offer","security":[{"secretKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The offer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartnerOffer"}}}},"404":{"description":"No such offer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Offers"],"operationId":"updatePartnerOffer","summary":"Update a partner offer","description":"Can change copy, price or pause state. Cannot refund a yes or change the host share.","security":[{"secretKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"headline":{"type":"string"},"body":{"type":"string"},"cta":{"type":"string"},"price_cents":{"type":"integer"},"status":{"enum":["live","paused"]}}}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartnerOffer"}}}},"404":{"description":"No such offer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/placements":{"get":{"tags":["Offers"],"operationId":"listPlacements","summary":"List offers a host has placed","security":[{"secretKey":[]}],"responses":{"200":{"description":"A list.","content":{"application/json":{"schema":{"type":"object","required":["object","data","has_more"],"properties":{"object":{"const":"list"},"data":{"type":"array","items":{"$ref":"#/components/schemas/Placement"}},"has_more":{"type":"boolean"}}}}}},"403":{"description":"Not a host key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Offers"],"operationId":"placeOffer","summary":"Place an offer on a host","description":"Approves an offer for this host. Does not charge anyone.","security":[{"secretKey":[]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Safe retries. The response is kept for 24 hours. Reusing a key with a different body returns 422.","schema":{"type":"string","maxLength":255}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["offer"],"properties":{"offer":{"type":"string"}}}}}},"responses":{"201":{"description":"Placed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Placement"}}}},"403":{"description":"Not a host key, or live mode is not approved.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such offer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/attribution_events":{"get":{"tags":["Leads"],"operationId":"listAttributionEvents","summary":"List attribution events","description":"Yes, consent, delivery, conversion and revocation events for this account. Includes `mj_id`.","security":[{"secretKey":[]}],"parameters":[{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":100}},{"name":"starting_after","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"A list.","content":{"application/json":{"schema":{"type":"object","required":["object","data","has_more"],"properties":{"object":{"const":"list"},"data":{"type":"array","items":{"$ref":"#/components/schemas/AttributionEvent"}},"has_more":{"type":"boolean"}}}}}},"401":{"description":"Missing or invalid secret key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/attribution_events/{id}":{"get":{"tags":["Leads"],"operationId":"getAttributionEvent","summary":"Get one attribution event","security":[{"secretKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The event.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AttributionEvent"}}}},"404":{"description":"No such event.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/webhook_endpoints/{id}/test":{"post":{"tags":["Webhook endpoints"],"operationId":"sendTestWebhook","summary":"Send a test event","description":"Sends `webhook.test` through the normal signed delivery. It does not create a yes.","security":[{"secretKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Sent.","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"object":{"const":"webhook_test"},"ok":{"type":"boolean"},"status":{"type":"string"},"type":{"const":"webhook.test"}}}}}},"404":{"description":"No such endpoint.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/sandbox/accounts":{"post":{"tags":["Agents"],"operationId":"createSandboxAccount","summary":"Create a test-mode account","description":"No API key. Returns test keys once. Rate limited. Live keys are not created. Partners pay per yes in test mode through the normal charge. A person must add a payment method and approve the account before live traffic.","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string","minLength":2,"maxLength":80},"role":{"enum":["host","partner","pair"],"default":"pair"},"agent":{"type":"string","maxLength":80},"owner_email":{"type":"string","format":"email"}}}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SandboxAccount"}}}},"429":{"description":"Too many sandbox accounts.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/sandbox/balance":{"post":{"tags":["Agents"],"operationId":"fundTestBalance","summary":"Add test-mode funds","description":"Same test-mode top-up as the dashboard. Cannot credit a live balance and does not change the price of a yes.","security":[{"secretKey":[]}],"parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Safe retries. The response is kept for 24 hours. Reusing a key with a different body returns 422.","schema":{"type":"string","maxLength":255}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["amount_cents"],"properties":{"amount_cents":{"type":"integer","description":"Cents. The dashboard minimum applies."}}}}}},"responses":{"201":{"description":"Funded in test mode.","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"object":{"const":"topup"},"amount_cents":{"type":"integer"},"status":{"type":"string"},"livemode":{"const":false}}}}}},"403":{"description":"Not a sandbox partner, or the key is live.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/sandbox/listeners":{"post":{"tags":["Webhook endpoints"],"operationId":"createSandboxListener","summary":"Create a test webhook inbox","description":"Munja delivers test events, including offer.accepted, into this inbox. The signing secret is returned once.","security":[{"secretKey":[]}],"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SandboxListener"}}}},"403":{"description":"Live keys cannot create an inbox.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/sandbox/inbox":{"get":{"tags":["Webhook endpoints"],"operationId":"readSandboxInbox","summary":"Read the test webhook inbox","security":[{"secretKey":[]}],"responses":{"200":{"description":"Events received.","content":{"application/json":{"schema":{"type":"object","required":["object","data","has_more"],"properties":{"object":{"const":"list"},"data":{"type":"array","items":{"$ref":"#/components/schemas/InboxEvent"}},"has_more":{"type":"boolean"}}}}}}}}}},"webhooks":{"offer.accepted":{"post":{"summary":"A customer said yes on your page (host)","description":"Sent to host (merchant) endpoints. Never has a name, email, phone or ZIP. Verify `X-Munja-Signature` and de-duplicate on the event id.","parameters":[{"name":"X-Munja-Signature","in":"header","required":true,"description":"`t=<unix seconds>,v1=<hex HMAC-SHA256 of \"t.body\" with the endpoint secret>`. Reject timestamps more than 5 minutes old.","schema":{"type":"string"}},{"name":"X-Munja-Event-Id","in":"header","schema":{"type":"string"}},{"name":"X-Munja-Delivery-Attempt","in":"header","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEvent"}}}},"responses":{"200":{"description":"Return any 2xx within 10 seconds. Anything else retries after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 24 hours."}}}}},"components":{"securitySchemes":{"secretKey":{"type":"http","scheme":"bearer","description":"Secret key `sk_test_...`. Server only. Create it under Settings, API keys in the console."}},"schemas":{"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["type","code","message"],"properties":{"type":{"enum":["invalid_request_error","authentication_error","permission_error","rate_limit_error","idempotency_error","api_error"]},"code":{"type":"string"},"message":{"type":"string"},"param":{"type":["string","null"]},"doc_url":{"type":"string"}}}}},"Surface":{"enum":["thank_you","exit","email","portal"],"default":"thank_you"},"EventType":{"enum":["lead.created","lead.refunded","refund_request.decided","offer.accepted","payout.paid","payout.failed","webhook.test"]},"DecideRequest":{"type":"object","required":["key","customer"],"properties":{"key":{"type":"string","pattern":"^pk_(test|live)_[A-Za-z0-9]{8,64}$","description":"Publishable key. Safe in a browser."},"order":{"type":"object","properties":{"id":{"type":"string","maxLength":120},"signature":{"type":"string","maxLength":128,"description":"Hex HMAC-SHA256 of `order_id.lowercased_email` with your signing secret (`mss_test_...`). Compute it on your server."}}},"moment":{"type":"string","maxLength":60},"surface":{"$ref":"#/components/schemas/Surface"},"context":{"type":"object","additionalProperties":true,"description":"Order facts that decide relevance, such as zip, newCustomer, orderTotal. Up to 4000 characters of JSON."},"customer":{"type":"object","properties":{"email":{"type":"string","maxLength":254},"name":{"type":"string","maxLength":120},"phone":{"type":"string","maxLength":40,"description":"Accepted and discarded."}}},"seconds_on_page":{"type":"number"},"page_url":{"type":"string","maxLength":500}}},"OfferList":{"type":"object","required":["object","livemode","data"],"properties":{"object":{"const":"offer_list"},"decision":{"type":["string","null"]},"livemode":{"type":"boolean"},"data":{"type":"array","items":{"$ref":"#/components/schemas/Offer"}},"moment":{"$ref":"#/components/schemas/Moment"},"empty_reason":{"type":"string","description":"Why the list is empty. For your developer, never for shoppers."},"drop_reasons":{"type":"array","items":{"type":"object","properties":{"reason":{"type":"string"},"n":{"type":"integer"}}}},"replayed":{"type":"boolean"},"agent":{"type":"boolean"}},"additionalProperties":true},"Moment":{"type":"object","properties":{"merchant":{"type":"string"},"eyebrow":{"type":"string"},"title":{"type":"string"},"brand":{"type":"string"},"layout":{"enum":["stack","pager","featured","compact"]},"font":{"type":"string"},"radius":{"type":"number"},"fine":{"type":"string"}},"additionalProperties":true},"Offer":{"type":"object","required":["impression","position","partner","category","headline","body","cta","consent","consent_version","yes_tier"],"properties":{"impression":{"type":"string","description":"The token for view, accept, dismiss and report."},"position":{"type":"integer"},"partner":{"type":"string"},"category":{"type":"string"},"headline":{"type":"string"},"body":{"type":"string"},"price":{"type":"string"},"perk":{"type":"string"},"cta":{"type":"string","description":"The button text."},"consent":{"type":"string","description":"The exact consent wording to show next to the button. Do not edit it."},"consent_version":{"type":"string"},"yes_tier":{"enum":["contact","call","quote"],"description":"What the yes collects."},"call_consent":{"type":"string","description":"For call and quote offers: the exact text next to the unchecked box."},"logo":{"type":"string"},"terms_url":{"type":"string"},"link_out":{"type":"boolean"},"offer_id":{"type":"string"},"accepted":{"type":"boolean"}},"additionalProperties":true},"Acceptance":{"type":"object","required":["object","status","lead"],"properties":{"object":{"const":"acceptance"},"lead":{"type":"string"},"status":{"type":"string","description":"`accepted`, or `duplicate` for an agent accept."},"partner":{"type":"string"},"message":{"type":"string"},"livemode":{"type":"boolean"},"offer_code":{"type":"string"},"landingUrl":{"type":"string"},"continueUrl":{"type":"string"},"source":{"type":"string"},"charged":{"type":"boolean"}},"additionalProperties":true},"AgentAcceptRequest":{"type":"object","required":["key","offer_id","consumer","order","attestation"],"properties":{"key":{"type":"string"},"offer_id":{"type":"string"},"consumer":{"type":"object","required":["name","email"],"properties":{"name":{"type":"string"},"email":{"type":"string","format":"email"}}},"order":{"type":"object","required":["id","date","zip"],"properties":{"id":{"type":"string"},"date":{"type":"string","format":"date"},"zip":{"type":"string","pattern":"^\\d{5}$"}}},"attestation":{"type":"object","required":["consumer_authorized","agent_name","statement","consent_token","consented_at"],"properties":{"consumer_authorized":{"const":true},"agent_name":{"type":"string","maxLength":80},"statement":{"type":"string","minLength":10,"maxLength":500},"consent_token":{"type":"string","minLength":16,"maxLength":512},"consented_at":{"type":"string","format":"date-time","description":"Within the last 24 hours."}}}}},"LeadCreate":{"type":"object","required":["offer_id","email","disclosure_text"],"properties":{"offer_id":{"type":"string"},"email":{"type":"string","format":"email","maxLength":254},"disclosure_text":{"type":"string","maxLength":2000},"contact":{"type":"object","additionalProperties":{"type":"string"}},"surface":{"type":"string","maxLength":40,"default":"api"}}},"Lead":{"type":"object","properties":{"id":{"type":"string"},"object":{"const":"lead"},"status":{"type":"string","description":"`charged` or `duplicate`."},"charged_amount":{"type":"integer","description":"Cents."},"duplicate_of":{"type":["string","null"]},"consent":{"type":"string"},"livemode":{"type":"boolean"}}},"LeadSummary":{"type":"object","properties":{"id":{"type":"string"},"object":{"const":"lead"},"offer":{"type":"string"},"partner":{"type":"string"},"merchant":{"type":"string"},"status":{"type":"string"},"amount":{"type":"integer","description":"Cents charged."},"mj_id":{"type":["string","null"]},"duplicate_of":{"type":["string","null"]},"quality_flags":{"type":"array","items":{"type":"string"}},"created":{"type":"integer","description":"Unix seconds."},"livemode":{"type":"boolean"}}},"Event":{"type":"object","properties":{"id":{"type":"string"},"object":{"const":"event"},"type":{"type":"string"},"created":{"type":"integer"},"livemode":{"type":"boolean"},"data":{"type":"object","additionalProperties":true}}},"CatalogItem":{"type":"object","additionalProperties":true,"description":"A partner offer or a host placement."},"PartnerOffer":{"type":"object","properties":{"id":{"type":"string"},"object":{"const":"partner_offer"},"headline":{"type":"string"},"body":{"type":"string"},"cta":{"type":"string"},"category":{"type":"string"},"price_cents":{"type":"integer","description":"What a yes charges."},"status":{"type":"string"},"pricing_model":{"const":"cpl"},"livemode":{"type":"boolean"},"created":{"type":"integer"}}},"PartnerOfferWrite":{"type":"object","required":["headline","body","price_cents"],"properties":{"headline":{"type":"string"},"body":{"type":"string"},"price_cents":{"type":"integer"},"cta":{"type":"string"},"category":{"type":"string"}}},"Placement":{"type":"object","properties":{"id":{"type":"string"},"object":{"const":"placement"},"offer":{"type":"string"},"status":{"type":"string"},"headline":{"type":"string"},"partner":{"type":"string"},"price_cents":{"type":"integer"},"livemode":{"type":"boolean"}}},"AttributionEvent":{"type":"object","properties":{"id":{"type":"string"},"object":{"const":"attribution_event"},"lead":{"type":"string"},"mj_id":{"type":["string","null"]},"kind":{"type":"string"},"payload":{"type":"object","additionalProperties":true},"created":{"type":"integer"},"livemode":{"type":"boolean"}}},"SandboxAccount":{"type":"object","properties":{"object":{"const":"sandbox_account"},"livemode":{"const":false},"billing":{"type":"string"},"host":{"type":["object","null"]},"partner":{"type":["object","null"]}}},"SandboxListener":{"type":"object","properties":{"id":{"type":"string"},"object":{"const":"sandbox_listener"},"url":{"type":"string"},"token":{"type":"string"},"secret":{"type":"string"},"events":{"type":"array","items":{"type":"string"}},"livemode":{"const":false}}},"InboxEvent":{"type":"object","properties":{"id":{"type":"string"},"object":{"const":"sandbox_inbox_event"},"body":{"type":"object","additionalProperties":true},"created":{"type":"integer"}}},"HostYes":{"type":"object","properties":{"id":{"type":"string"},"object":{"const":"yes"},"offer":{"type":"string"},"status":{"type":"string"},"amount":{"type":"integer"},"created":{"type":"string","format":"date-time"},"livemode":{"const":false}}},"WebhookEndpoint":{"type":"object","properties":{"id":{"type":"string"},"object":{"const":"webhook_endpoint"},"url":{"type":"string"},"events":{"type":"array","items":{"type":"string"}},"status":{"type":"string"},"livemode":{"type":"boolean"}}},"WebhookEndpointCreated":{"type":"object","properties":{"id":{"type":"string"},"object":{"const":"webhook_endpoint"},"secret":{"type":"string","description":"`whsec_...`. Shown once."},"events":{"type":"array","items":{"type":"string"}},"livemode":{"type":"boolean"}}},"EventSummary":{"type":"object","properties":{"id":{"type":"string"},"object":{"const":"event"},"type":{"type":"string"},"created":{"type":"integer"},"livemode":{"type":"boolean"}}},"Conversion":{"type":"object","properties":{"id":{"type":"string"},"object":{"const":"conversion"},"lead":{"type":["string","null"]},"mj_click_id":{"type":["string","null"]},"type":{"type":"string"},"value":{"type":["integer","null"]},"currency":{"type":"string"},"occurred_at":{"type":"integer"},"source":{"type":"string"},"match_method":{"type":["string","null"]},"external_id":{"type":"string"},"within_window":{"type":"boolean"},"livemode":{"type":"boolean"}}},"WebhookEvent":{"type":"object","required":["id","object","type","livemode","created","data"],"properties":{"id":{"type":"string"},"object":{"const":"event"},"type":{"$ref":"#/components/schemas/EventType"},"livemode":{"type":"boolean"},"created":{"type":"integer","description":"Unix seconds."},"data":{"type":"object","properties":{"object":{"type":"object","additionalProperties":true,"description":"For `offer.accepted`: id, offer, partner, price_cents, merchant_share_cents, surface, yes_tier, source, status, created."}}}}}}}}