{"openapi":"3.1.0","info":{"title":"POST /api/v1/vendors","version":"1.0.0","description":"Create vendor"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/vendors":{"post":{"tags":["vendors"],"summary":"Create vendor","description":"Add a new supplier/vendor.","operationId":"create_vendor","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Authorization"}},{"name":"x-business-id","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Business-Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VendorCreateRequest"},"example":{"address":"123 Industrial Way, Oakland, CA 94612","category":"Raw Materials","email":"orders@acmesupplies.com","name":"Acme Supplies","phone":"(555) 987-6543","status":"active","tax_id":"98-7654321","website":"https://acmesupplies.com"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_VendorResponse_"}}}},"400":{"description":"Bad Request - Invalid input","content":{"application/json":{"example":{"error":"validation_error","message":"Validation failed: due_date: Input should be a valid date","errors":{"due_date":"Input should be a valid date"},"code":"GEN_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized - Missing or expired token, an MCP OAuth token used against the REST API, or no access to this business","content":{"application/json":{"example":{"error":"unauthorized","message":"Authentication required","code":"AUTH_001","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"example":{"error":"forbidden","message":"You don't have permission to access this resource","code":"AUTH_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"error":"validation_error","message":"Validation failed: amount: Input should be a valid integer","errors":{"amount":"Input should be a valid integer"},"code":"GEN_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"}}}}},"x-fastapi-operation-id":"create_vendor_api_v1_vendors_post"}}},"components":{"schemas":{"CounterpartyStatus":{"type":"string","enum":["active","inactive","blocked"],"title":"CounterpartyStatus","description":"Status values for customers and vendors."},"SuccessEnvelope_VendorResponse_":{"properties":{"success":{"type":"boolean","title":"Success","default":true},"message":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Message"},"code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Code"},"data":{"anyOf":[{"$ref":"#/components/schemas/VendorResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[VendorResponse]"},"VendorApprovalRouteResponse":{"properties":{"id":{"type":"string","title":"Id"},"business_id":{"type":"string","title":"Business Id"},"vendor_id":{"type":"string","title":"Vendor Id"},"vendor_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Vendor Name"},"approver_user_ids":{"items":{"type":"string"},"type":"array","title":"Approver User Ids"},"require_all":{"type":"boolean","title":"Require All"},"ledger_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Ledger Id"},"ledger_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Ledger Name"},"max_amount_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Max Amount Cents"},"active":{"type":"boolean","title":"Active"},"created_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Created At"},"updated_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Updated At"}},"type":"object","required":["id","business_id","vendor_id","approver_user_ids","require_all","active"],"title":"VendorApprovalRouteResponse","description":"One vendor approval route."},"VendorContactResponse":{"properties":{"id":{"type":"string","title":"Id","description":"Contact UUID."},"vendor_id":{"type":"string","title":"Vendor Id","description":"Vendor UUID."},"name":{"type":"string","title":"Name","description":"Contact name."},"email":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Email","description":"Contact email."},"phone":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Phone","description":"Contact phone."},"role":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Role","description":"Contact role (e.g., 'Sales', 'Support')."},"is_primary":{"type":"boolean","title":"Is Primary","description":"Whether this is the primary contact.","default":false},"notes":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Notes","description":"Notes about this contact."},"created_at":{"type":"string","format":"date-time","title":"Created At","description":"Creation timestamp."},"updated_at":{"type":"string","format":"date-time","title":"Updated At","description":"Last update timestamp."}},"type":"object","required":["id","vendor_id","name","created_at","updated_at"],"title":"VendorContactResponse","description":"Response schema for a vendor contact."},"VendorCreateRequest":{"properties":{"name":{"type":"string","minLength":1,"title":"Name","description":"Vendor name (company or individual)."},"email":{"anyOf":[{"type":"string","format":"email"},{"type":"null"}],"title":"Email","description":"Vendor email for communications. Optional; without it the vendor is matched by name, so a second vendor with the same name is refused."},"address":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Address","description":"Vendor business address."},"phone":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Phone","description":"Vendor phone number."},"tax_id":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Tax Id","description":"Tax identification number (EIN, VAT, etc.)."},"website":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Website","description":"Vendor website URL."},"notes":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Notes","description":"Internal notes about this vendor."},"credit_limit_cents":{"anyOf":[{"type":"integer","minimum":0.0},{"type":"null"}],"title":"Credit Limit Cents","description":"Credit limit in cents."},"default_payment_term_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Default Payment Term Id","description":"Default payment term ID for new bills."},"status":{"$ref":"#/components/schemas/CounterpartyStatus","description":"Vendor status (active, inactive, blocked).","default":"active"},"category":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Category","description":"Business category (e.g., 'Raw Materials', 'Services')."}},"type":"object","required":["name"],"title":"VendorCreateRequest","description":"Request schema for creating a new vendor.\n\nVendors are the companies or individuals you purchase from and receive bills from.\nSupports credit limits, default payment terms, tax IDs, and categorization.","example":{"address":"123 Industrial Way, Oakland, CA 94612","category":"Raw Materials","email":"orders@acmesupplies.com","name":"Acme Supplies","phone":"(555) 987-6543","status":"active","tax_id":"98-7654321","website":"https://acmesupplies.com"},"examples":[{"address":"123 Industrial Way, Oakland, CA 94612","category":"Raw Materials","email":"orders@acmesupplies.com","name":"Acme Supplies","phone":"(555) 987-6543","status":"active","tax_id":"98-7654321","website":"https://acmesupplies.com"}]},"VendorResponse":{"properties":{"id":{"type":"string","title":"Id","description":"Vendor UUID."},"business_id":{"type":"string","title":"Business Id","description":"Business UUID."},"name":{"type":"string","title":"Name","description":"Vendor name."},"email":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Email","description":"Vendor email address."},"address":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Address","description":"Vendor business address."},"phone":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Phone","description":"Vendor phone number."},"tax_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Tax Id","description":"Tax identification number."},"website":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Website","description":"Vendor website URL."},"notes":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Notes","description":"Internal notes."},"credit_limit_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Credit Limit Cents","description":"Credit limit in cents."},"default_payment_term_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Default Payment Term Id","description":"Default payment term ID."},"status":{"type":"string","title":"Status","description":"Vendor status.","default":"active"},"category":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Category","description":"Business category."},"default_location_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Default Location Id","description":"Default ship-from location ID for purchase orders."},"default_location_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Default Location Name","description":"Default ship-from location name (resolved)."},"registry_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Registry Id","description":"Counterparty registry entry this vendor is linked to; null when unlinked."},"registry_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Registry Name","description":"Canonical name of the linked registry entry (resolved)."},"is_deleted":{"type":"boolean","title":"Is Deleted","description":"Whether vendor is soft deleted.","default":false},"deleted_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Deleted At","description":"Timestamp when vendor was deleted."},"created_at":{"type":"string","format":"date-time","title":"Created At","description":"Creation timestamp."},"updated_at":{"type":"string","format":"date-time","title":"Updated At","description":"Last update timestamp."},"contacts":{"anyOf":[{"items":{"$ref":"#/components/schemas/VendorContactResponse"},"type":"array"},{"type":"null"}],"title":"Contacts","description":"Vendor contacts."},"approval_route":{"anyOf":[{"$ref":"#/components/schemas/VendorApprovalRouteResponse"},{"type":"null"}],"description":"The vendor's approval route for bills on any ledger (or its only route); null when its bills route by amount. Single-vendor reads only."},"approval_routes":{"anyOf":[{"items":{"$ref":"#/components/schemas/VendorApprovalRouteResponse"},"type":"array"},{"type":"null"}],"title":"Approval Routes","description":"Every approval route of the vendor, per ledger. Single-vendor reads only."}},"additionalProperties":true,"type":"object","required":["id","business_id","name","created_at","updated_at"],"title":"VendorResponse","description":"Response schema for a vendor.\n\nVendors are companies or individuals you purchase from.\nThey are linked to bills for expense tracking.","example":{"address":"123 Industrial Way, Oakland, CA 94612","business_id":"019ab37c-b051-7000-8000-000000000001","category":"Raw Materials","created_at":"2024-01-10T10:30:00Z","email":"orders@acmesupplies.com","id":"019ab37c-ae0d-7000-8000-000000000001","name":"Acme Supplies","phone":"(555) 987-6543","status":"active","tax_id":"98-7654321","updated_at":"2024-01-15T14:00:00Z"},"examples":[{"address":"123 Industrial Way, Oakland, CA 94612","business_id":"019ab37c-b051-7000-8000-000000000001","category":"Raw Materials","created_at":"2024-01-10T10:30:00Z","email":"orders@acmesupplies.com","id":"019ab37c-ae0d-7000-8000-000000000001","name":"Acme Supplies","phone":"(555) 987-6543","status":"active","tax_id":"98-7654321","updated_at":"2024-01-15T14:00:00Z"}]},"ErrorResponse":{"title":"ErrorResponse","type":"object","description":"Envelope returned by every non-2xx response. Branch on `code` (stable) rather than `message` (human-readable, may change).","required":["error","message","code"],"properties":{"error":{"type":"string","description":"Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`."},"message":{"type":"string","description":"Human-readable explanation, safe to show to end users."},"code":{"type":"string","description":"Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`)."},"request_id":{"type":"string","description":"Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied."},"errors":{"type":"object","additionalProperties":{"type":"string"},"description":"Field-level validation messages keyed by field name. Present on 400/422 validation failures only."}}}},"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Token","description":"API token authentication. Format: `Bearer dz_...`"}}},"security":[{"BearerAuth":[]}]}