post
https://api.weatherit.ai/v1/quotes/multi//purchase
Purchase all quotes in a multi-quote batch with a single payment transaction. Each quote can have its own booking reference.
This operation is idempotent — use X-Request-Id for safe retries.
Recent Requests
Log in to see full request history
| Time | Status | User Agent | |
|---|---|---|---|
Retrieving recent requests… | |||
Loading…
Atomic Purchase Flow
sequenceDiagram
participant P as Partner
participant API as WeatherIT API
participant DB as Database
P->>API: POST /quotes/multi/{id}/purchase<br/>+ X-Request-Id (idempotency)
API->>API: Check idempotency cache (7-day TTL)
API->>DB: Validate all quotes in batch
loop For each quote (sequential)
API->>DB: accept_and_pay_quote
alt Success
DB-->>API: Policy created
else Failure
DB-->>API: Error
Note over API: Entire batch fails
API-->>P: 500 TRANSACTION_FAILED
end
end
API-->>P: 200 All policies created
What This Endpoint Does
- Validates Batch: Confirms all quotes in the batch are still valid
- Atomic Purchase: Purchases all selected quotes together or none
- Creates Policies: Generates policy numbers and activates coverage for each
- Returns Summary: Provides transaction details and all created policies
When to Use This Endpoint
Call this endpoint when:
- Customer has selected coverage options from a multi-quote batch
- Payment has been processed for the combined total
- You want to create multiple policies in a single transaction
- You need rollback protection (all succeed or none)
Request Parameters
| Parameter | Required | Description |
|---|---|---|
| customer.email | Yes | Customer email for policy documents |
| customer.firstName | Yes | Customer first name (min 2 chars) |
| customer.lastName | Yes | Customer last name (min 1 char) |
| customer.phone | No | Contact phone for claims support |
| payment.transactionId | Yes | Your payment processor's transaction ID |
| purchases[].quoteId | Yes | Quote ID to purchase (from pricing_options) |
| purchases[].bookingReference | No | Booking reference for this specific quote |
| bookingReference | No | Shared booking reference for all quotes |
Understanding the Response
multi_purchase object contains:
| Field | Description |
|---|---|
| multi_id | UUID of the multi-quote batch |
| transaction_id | Your payment reference |
| policies[] | Array of created policies |
| payment | Combined payment summary |
policies[] for each policy:
| Field | Description |
|---|---|
| quote_id | Original quote purchased |
| policy_id | UUID for policy operations |
| policy_number | Human-readable reference (e.g., "WIT-2025-00001") |
| status | Policy status (typically "active") |
| premium_paid | Premium for this policy |
payment summary:
| Field | Description |
|---|---|
| total_amount | Combined premium for all policies |
| currency | Currency code (e.g., "AUD") |
| status | Payment status |
| transaction_timestamp | When purchase was processed |
Error Handling
| Error | Code | Description |
|---|---|---|
| MULTI_QUOTE_NOT_FOUND | 404 | Batch doesn't exist |
| QUOTE_EXPIRED | 410 | One or more quotes have expired |
| QUOTE_ALREADY_CONVERTED | 409 | Quote already purchased |
| VALIDATION_ERROR | 400 | Missing/invalid request fields |
| PARTIAL_FAILURE | 422 | Some quotes failed validation - entire transaction rolled back |
Idempotency
Include X-Request-Id header for safe retries. The endpoint caches responses for 168 hours (7 days) - retrying with the same request-id returns the original response.
Best Practices
- Verify totals: Ensure payment amount matches sum of selected quote premiums
- Use idempotency: Always include X-Request-Id for production requests
- Store all policy_ids: Each policy in the batch may need individual operations later
- Handle rollbacks: If purchase fails, the entire batch is rolled back - create new quotes
Next Steps
After successful purchase:
- Send confirmation email with all policy numbers
- Store each policy_id linked to your bookings
- Use
GET /policies/{id}to retrieve individual policy details - Use
POST /policies/{id}/cancelif a booking is cancelled
