{"openapi":"3.1.0","info":{"title":"PortSaid Integrations API","version":"1.0.0","description":"API keys are scoped to a single company and independent of staff sign-in. Keep keys on your integration server. This deployment uses isolated staging data."},"servers":[{"url":"https://stage-api.portsaid.com.tr","description":"Staging"}],"paths":{"/api/health":{"get":{"summary":"Check database connectivity","responses":{"200":{"description":"Success.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","const":true}},"required":["ok"],"additionalProperties":false}}}},"503":{"description":"Success.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","const":false}},"required":["ok"],"additionalProperties":false}}}}}}},"/api/v1/customers":{"get":{"summary":"Look up a customer by phone","security":[{"bearerAuth":[]}],"x-required-scope":"customers:read","responses":{"200":{"description":"Success.","content":{"application/json":{"schema":{"type":"object","properties":{"customer":{"anyOf":[{"type":"object","properties":{"id":{"type":"string","format":"uuid","pattern":"^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"},"companyName":{"type":"string"},"contactName":{"type":["string","null"]},"tier":{"type":"string"},"paymentTerms":{"anyOf":[{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},{"type":"null"}]},"salesRep":{"type":["string","null"]},"waOptin":{"type":"boolean"}},"required":["id","companyName","contactName","tier","paymentTerms","salesRep","waOptin"],"additionalProperties":false},{"type":"null"}]}},"required":["customer"],"additionalProperties":false}}}},"400":{"description":"Missing or invalid input.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"invalid_request"},"issues":{"type":"array","items":{"type":"string"}}},"required":["error","issues"],"additionalProperties":false}}}},"401":{"description":"Bearer token missing, invalid, revoked, or missing the required scope.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"unauthorized"}},"required":["error"],"additionalProperties":false}}},"headers":{"WWW-Authenticate":{"schema":{"type":"string","const":"Bearer"}}}},"500":{"description":"Unexpected server error.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"internal_error"}},"required":["error"],"additionalProperties":false}}}}},"parameters":[{"in":"query","name":"phone","required":true,"schema":{"type":"string","minLength":5,"maxLength":64,"pattern":"\\d"},"example":"+905551112233"}]}},"/api/v1/products":{"get":{"summary":"List active, sellable products and prices approved for sharing","security":[{"bearerAuth":[]}],"x-required-scope":"products:read","responses":{"200":{"description":"Success.","content":{"application/json":{"schema":{"type":"object","properties":{"products":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","pattern":"^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"},"code":{"type":"string"},"name":{"type":"string"},"names":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"type":"string"}},"category":{"type":["string","null"]},"unit":{"type":"string"},"attrs":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"type":["string","number"]}},"imageIds":{"type":"array","items":{"type":"string","format":"uuid","pattern":"^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"}},"prices":{"type":"array","items":{"type":"object","properties":{"variant":{"type":"string"},"unit":{"type":"string"},"price":{"type":"number"},"currency":{"type":"string"},"minQty":{"type":"number"},"validUntil":{"anyOf":[{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"},{"type":"null"}]}},"required":["variant","unit","price","currency","minQty","validUntil"],"additionalProperties":false}}},"required":["id","code","name","names","category","unit","attrs","imageIds","prices"],"additionalProperties":false}}},"required":["products"],"additionalProperties":false}}}},"400":{"description":"Missing or invalid input.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"invalid_request"},"issues":{"type":"array","items":{"type":"string"}}},"required":["error","issues"],"additionalProperties":false}}}},"401":{"description":"Bearer token missing, invalid, revoked, or missing the required scope.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"unauthorized"}},"required":["error"],"additionalProperties":false}}},"headers":{"WWW-Authenticate":{"schema":{"type":"string","const":"Bearer"}}}},"500":{"description":"Unexpected server error.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"internal_error"}},"required":["error"],"additionalProperties":false}}}}},"parameters":[{"in":"query","name":"q","description":"Search code, name and translated names.","schema":{"type":"string","maxLength":300}},{"in":"query","name":"category","description":"Exact product category.","schema":{"type":"string","maxLength":300}},{"in":"query","name":"limit","schema":{"type":"integer","minimum":1,"maximum":100,"default":30}}]}},"/api/v1/products/images/{id}":{"get":{"summary":"Download a product image from the same company catalog","security":[{"bearerAuth":[]}],"x-required-scope":"products:read","parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid","pattern":"^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"}}],"responses":{"200":{"description":"The original stored image.","content":{"image/jpeg":{"schema":{"type":"string","format":"binary"}},"image/png":{"schema":{"type":"string","format":"binary"}}}},"401":{"description":"Bearer token missing, invalid, revoked, or missing the required scope.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"unauthorized"}},"required":["error"],"additionalProperties":false}}},"headers":{"WWW-Authenticate":{"schema":{"type":"string","const":"Bearer"}}}},"404":{"description":"Image unavailable for this catalog.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"not_found"}},"required":["error"],"additionalProperties":false}}}},"500":{"description":"Unexpected server error.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"internal_error"}},"required":["error"],"additionalProperties":false}}}}}}},"/api/v1/quotes":{"post":{"summary":"Create a quote request for staff","security":[{"bearerAuth":[]}],"x-required-scope":"quotes:write","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"source":{"default":"api","type":"string","maxLength":300},"phone":{"type":"string","minLength":5,"maxLength":64,"pattern":"\\d"},"name":{"type":"string","maxLength":300},"company":{"type":"string","maxLength":300},"email":{"type":"string","maxLength":254,"format":"email","pattern":"^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"},"items":{"minItems":1,"maxItems":100,"type":"array","items":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":300},"qty":{"type":"number","exclusiveMinimum":0},"unit":{"default":"adet","type":"string","maxLength":300},"sku":{"type":"string","maxLength":300},"note":{"type":"string","maxLength":4000},"specs":{"type":"object","propertyNames":{"type":"string","minLength":1,"maxLength":80},"additionalProperties":{"anyOf":[{"type":"string","maxLength":200},{"type":"number"}]}}},"required":["name","qty"]}},"notes":{"type":"string","maxLength":4000},"externalRef":{"type":"string","maxLength":300}},"required":["items"]}}}},"responses":{"200":{"description":"Success.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","const":true},"id":{"type":"string","format":"uuid","pattern":"^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"},"number":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}},"required":["ok","id","number"],"additionalProperties":false}}}},"400":{"description":"Missing or invalid input.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"invalid_request"},"issues":{"type":"array","items":{"type":"string"}}},"required":["error","issues"],"additionalProperties":false}}}},"401":{"description":"Bearer token missing, invalid, revoked, or missing the required scope.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"unauthorized"}},"required":["error"],"additionalProperties":false}}},"headers":{"WWW-Authenticate":{"schema":{"type":"string","const":"Bearer"}}}},"500":{"description":"Unexpected server error.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"internal_error"}},"required":["error"],"additionalProperties":false}}}}},"description":"A new request is created on each successful call, including when the same externalRef is used."}},"/api/v1/tasks":{"post":{"summary":"Create a task and link a matching customer when possible","security":[{"bearerAuth":[]}],"x-required-scope":"tasks:write","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":300},"detail":{"type":"string","maxLength":4000},"assignee":{"type":"string","maxLength":300},"source":{"default":"bot","type":"string","maxLength":300},"dueAt":{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"},"phone":{"type":"string","minLength":5,"maxLength":64,"pattern":"\\d"}},"required":["title"]}}}},"responses":{"200":{"description":"Success.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","const":true},"id":{"type":"string","format":"uuid","pattern":"^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"}},"required":["ok","id"],"additionalProperties":false}}}},"400":{"description":"Missing or invalid input.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"invalid_request"},"issues":{"type":"array","items":{"type":"string"}}},"required":["error","issues"],"additionalProperties":false}}}},"401":{"description":"Bearer token missing, invalid, revoked, or missing the required scope.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"unauthorized"}},"required":["error"],"additionalProperties":false}}},"headers":{"WWW-Authenticate":{"schema":{"type":"string","const":"Bearer"}}}},"500":{"description":"Unexpected server error.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"internal_error"}},"required":["error"],"additionalProperties":false}}}}}}},"/api/v1/messages":{"post":{"summary":"Record an inbound or outbound message","security":[{"bearerAuth":[]}],"x-required-scope":"messages:write","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"phone":{"type":"string","minLength":5,"maxLength":64,"pattern":"\\d"},"direction":{"type":"string","enum":["in","out"]},"author":{"default":"customer","type":"string","enum":["customer","bot","staff"]},"text":{"type":"string","minLength":1,"maxLength":8000},"customerName":{"type":"string","maxLength":300},"topic":{"type":"string","maxLength":300},"needsFollowup":{"type":"boolean"},"followupReason":{"type":"string","maxLength":4000},"waMessageId":{"type":"string","maxLength":300}},"required":["phone","direction","text"]}}}},"responses":{"200":{"description":"Success.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","const":true},"duplicate":{"type":"boolean"},"id":{"type":"string","format":"uuid","pattern":"^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"}},"required":["ok","duplicate"],"additionalProperties":false}}}},"400":{"description":"Missing or invalid input.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"invalid_request"},"issues":{"type":"array","items":{"type":"string"}}},"required":["error","issues"],"additionalProperties":false}}}},"401":{"description":"Bearer token missing, invalid, revoked, or missing the required scope.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"unauthorized"}},"required":["error"],"additionalProperties":false}}},"headers":{"WWW-Authenticate":{"schema":{"type":"string","const":"Bearer"}}}},"500":{"description":"Unexpected server error.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"internal_error"}},"required":["error"],"additionalProperties":false}}}}},"description":"Supply a stable waMessageId for deduplication. This operation records the message in the database."}},"/api/v1/conversations/pause":{"post":{"summary":"Pause bot replies for a conversation","security":[{"bearerAuth":[]}],"x-required-scope":"messages:write","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"phone":{"type":"string","minLength":5,"maxLength":64,"pattern":"\\d"},"hours":{"type":"number","minimum":0.1,"maximum":720},"reason":{"type":"string","maxLength":200}},"required":["phone"]}}}},"responses":{"200":{"description":"Success.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","const":true},"pausedUntil":{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"}},"required":["ok","pausedUntil"],"additionalProperties":false}}}},"400":{"description":"Missing or invalid input.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"invalid_request"},"issues":{"type":"array","items":{"type":"string"}}},"required":["error","issues"],"additionalProperties":false}}}},"401":{"description":"Bearer token missing, invalid, revoked, or missing the required scope.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"unauthorized"}},"required":["error"],"additionalProperties":false}}},"headers":{"WWW-Authenticate":{"schema":{"type":"string","const":"Bearer"}}}},"500":{"description":"Unexpected server error.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"internal_error"}},"required":["error"],"additionalProperties":false}}}}}}},"/api/v1/conversations/resume":{"post":{"summary":"Resume bot replies for a conversation","security":[{"bearerAuth":[]}],"x-required-scope":"messages:write","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"phone":{"type":"string","minLength":5,"maxLength":64,"pattern":"\\d"}},"required":["phone"]}}}},"responses":{"200":{"description":"Success.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","const":true}},"required":["ok"],"additionalProperties":false}}}},"400":{"description":"Missing or invalid input.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"invalid_request"},"issues":{"type":"array","items":{"type":"string"}}},"required":["error","issues"],"additionalProperties":false}}}},"401":{"description":"Bearer token missing, invalid, revoked, or missing the required scope.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"unauthorized"}},"required":["error"],"additionalProperties":false}}},"headers":{"WWW-Authenticate":{"schema":{"type":"string","const":"Bearer"}}}},"500":{"description":"Unexpected server error.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"internal_error"}},"required":["error"],"additionalProperties":false}}}}}}},"/api/v1/bot/reply":{"post":{"summary":"Prepare and log a reply for an inbound message","security":[{"bearerAuth":[]}],"x-required-scope":"bot:reply","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"phone":{"type":"string","minLength":5,"maxLength":64,"pattern":"\\d"},"text":{"type":"string","minLength":1,"maxLength":4000},"customerName":{"type":"string","maxLength":300},"waMessageId":{"type":"string","maxLength":300},"rules":{"type":"string","maxLength":20000}},"required":["phone","text"]}}}},"responses":{"200":{"description":"Success.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"ok":{"type":"boolean","const":true},"duplicate":{"type":"boolean","const":true}},"required":["ok","duplicate"],"additionalProperties":false},{"type":"object","properties":{"ok":{"type":"boolean","const":true},"paused":{"type":"boolean","const":true},"pausedUntil":{"anyOf":[{"type":"string","format":"date-time","pattern":"^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"},{"type":"null"}]}},"required":["ok","paused","pausedUntil"],"additionalProperties":false},{"type":"object","properties":{"ok":{"type":"boolean","const":true},"reply":{"type":"string"},"action":{"type":"string"},"path":{"type":"string","enum":["deterministic","model","failed","budget","cache"]},"handoff":{"anyOf":[{"type":"object","properties":{"needed":{"type":"boolean"},"reason":{"type":"string"},"intent":{"type":"string"}},"required":["needed","reason","intent"],"additionalProperties":false},{"type":"null"}]},"language":{"type":"string"},"issues":{"type":"array","items":{"type":"string"}},"ms":{"type":"number"},"costUsd":{"type":"number"},"photos":{"type":"array","items":{"type":"object","properties":{"url":{"type":"string"},"name":{"type":"string"},"productUrl":{"type":"string"},"storedImageId":{"type":"string","format":"uuid","pattern":"^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"}},"required":["url","name","productUrl"],"additionalProperties":false}}},"required":["ok","reply","action","path","handoff","language","issues","ms","costUsd"],"additionalProperties":false}]}}}},"400":{"description":"Missing or invalid input.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"invalid_request"},"issues":{"type":"array","items":{"type":"string"}}},"required":["error","issues"],"additionalProperties":false}}}},"401":{"description":"Bearer token missing, invalid, revoked, or missing the required scope.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"unauthorized"}},"required":["error"],"additionalProperties":false}}},"headers":{"WWW-Authenticate":{"schema":{"type":"string","const":"Bearer"}}}},"500":{"description":"Unexpected server error.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"internal_error"}},"required":["error"],"additionalProperties":false}}}},"503":{"description":"The model provider is unavailable on this deployment.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","const":"bot_unavailable"}},"required":["error"],"additionalProperties":false}}}}},"description":"The caller delivers the returned reply to the channel. A duplicate or paused result produces no reply. Photo results can contain storedImageId for the image endpoint, which requires products:read."}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer"}}}}