{"openapi":"3.1.0","info":{"title":"WA-OTP API","version":"1.0.0","description":"Reverse phone verification over WhatsApp. The end user sends a short code (VRF-XXXXX) to one of our numbers; we never initiate conversations in reverse mode."},"servers":[{"url":"https://api.technoenjaz.com"}],"tags":[{"name":"verifications"},{"name":"otp"},{"name":"accounts"},{"name":"admin"},{"name":"ops"}],"components":{"parameters":{"VerificationId":{"name":"id","in":"path","required":true,"schema":{"type":"string"},"examples":{"default":{"value":"ver_1a2B3c4d5E6f7G8h9I0j"}}}},"responses":{"BadRequest":{"description":"validation_error | invalid_phone | invalid_code | ttl_out_of_range","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"Unauthorized":{"description":"invalid_api_key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"Forbidden":{"description":"tenant_suspended | forward_mode_disabled | insufficient_scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"NotFound":{"description":"verification_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"Conflict":{"description":"verification_not_pending","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"RateLimited":{"description":"rate_limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"NoAccount":{"description":"no_available_account","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}},"securitySchemes":{"ApiKey":{"type":"http","scheme":"bearer","bearerFormat":"wo_live_...","description":"Tenant API key. Only sha256(key) is stored server-side."},"InternalToken":{"type":"http","scheme":"bearer","description":"INTERNAL_TOKEN. `/admin/*` is not exposed publicly."}},"schemas":{"ApiError":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message","request_id"],"properties":{"code":{"type":"string","enum":["validation_error","invalid_phone","invalid_code","ttl_out_of_range","invalid_api_key","tenant_suspended","forward_mode_disabled","insufficient_scope","verification_not_found","verification_not_pending","idempotency_conflict","verification_expired","rate_limited","too_many_attempts","internal_error","no_available_account","not_found","unauthorized","forbidden"]},"message":{"type":"string"},"details":{"type":"object","additionalProperties":true},"request_id":{"type":"string","examples":["req_ab12cd34ef56"]}}}}},"Verification":{"type":"object","required":["id","mode","status","expires_at"],"properties":{"id":{"type":"string","examples":["ver_1a2B3c"]},"mode":{"type":"string","enum":["reverse_phone","reverse_any","forward"]},"status":{"type":"string","enum":["pending","verified","expired","phone_mismatch","failed","cancelled"]},"phone":{"type":["string","null"],"examples":["+963912345678"]},"verified_phone":{"type":["string","null"]},"verified_at":{"type":["string","null"],"format":"date-time"},"expires_at":{"type":"string","format":"date-time"},"metadata":{"type":"object","additionalProperties":true}}},"CreateVerificationRequest":{"type":"object","additionalProperties":false,"properties":{"phone":{"type":"string","description":"E.164. Present => reverse_phone, absent => reverse_any"},"ttl_seconds":{"type":"integer","minimum":30,"maximum":300,"default":60},"locale":{"type":"string","enum":["ar","en"]},"end_user_ip":{"type":"string"},"metadata":{"type":"object","additionalProperties":true}}},"CreateVerificationResponse":{"allOf":[{"$ref":"#/components/schemas/Verification"},{"type":"object","properties":{"code":{"type":"string","pattern":"\\bVRF-([A-HJ-NP-Z2-9]{5})\\b","examples":["VRF-7K3Q9"]},"wa_number":{"type":"string"},"wa_link":{"type":"string","format":"uri"},"wa_deep_link":{"type":"string"}}}]},"AccountStatus":{"type":"object","properties":{"reverse_available":{"type":"boolean"},"forward_available":{"type":"boolean"}}}}},"security":[{"ApiKey":[]}],"paths":{"/v1/verifications":{"post":{"tags":["verifications"],"summary":"Start a reverse verification","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateVerificationRequest"}}}},"responses":{"201":{"description":"Verification created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateVerificationResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"},"503":{"$ref":"#/components/responses/NoAccount"}}}},"/v1/verifications/{id}":{"get":{"tags":["verifications"],"summary":"Get a verification (never returns the code)","parameters":[{"$ref":"#/components/parameters/VerificationId"}],"responses":{"200":{"description":"Verification","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Verification"}}}},"404":{"$ref":"#/components/responses/NotFound"}}},"delete":{"tags":["verifications"],"summary":"Cancel a pending verification","parameters":[{"$ref":"#/components/parameters/VerificationId"}],"responses":{"200":{"description":"Cancelled verification","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Verification"}}}},"409":{"$ref":"#/components/responses/Conflict"}}}},"/v1/verifications/{id}/wait":{"get":{"tags":["verifications"],"summary":"Long-poll until the status changes (Redis Pub/Sub, no DB polling)","parameters":[{"$ref":"#/components/parameters/VerificationId"},{"name":"timeout","in":"query","required":false,"schema":{"type":"integer","minimum":5,"maximum":60,"default":30}}],"responses":{"200":{"description":"Verification","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Verification"}}}}}}},"/v1/otp/send":{"post":{"tags":["otp"],"summary":"Send a forward OTP (never runs until forward is enabled for the tenant)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["phone"],"additionalProperties":false,"properties":{"phone":{"type":"string"},"locale":{"type":"string"},"ttl_seconds":{"type":"integer","minimum":30,"maximum":300},"metadata":{"type":"object","additionalProperties":true}}}}}},"responses":{"201":{"description":"OTP queued"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"}}}},"/v1/otp/check":{"post":{"tags":["otp"],"summary":"Check a forward OTP","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["id","code"],"additionalProperties":false,"properties":{"id":{"type":"string"},"code":{"type":"string"}}}}}},"responses":{"200":{"description":"Result"},"400":{"$ref":"#/components/responses/BadRequest"},"410":{"description":"verification_expired"},"429":{"description":"too_many_attempts"}}}},"/v1/accounts/status":{"get":{"tags":["accounts"],"summary":"Coarse availability for the current tenant","responses":{"200":{"description":"Availability","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountStatus"}}}}}}},"/healthz":{"get":{"tags":["ops"],"security":[],"summary":"Liveness","responses":{"200":{"description":"Alive"}}}},"/readyz":{"get":{"tags":["ops"],"security":[],"summary":"Readiness (Postgres + Redis)","responses":{"200":{"description":"Ready"},"503":{"description":"Not ready"}}}},"/metrics":{"get":{"tags":["ops"],"security":[],"summary":"Prometheus metrics (guarded by METRICS_TOKEN when set)","responses":{"200":{"description":"Metrics text"}}}},"/status":{"get":{"tags":["ops"],"security":[],"summary":"Safe public summary for the dashboard/landing page","responses":{"200":{"description":"Summary"}}}},"/openapi.json":{"get":{"tags":["ops"],"security":[],"summary":"This document","responses":{"200":{"description":"OpenAPI 3.1 document"}}}},"/admin/mock/inject":{"post":{"tags":["admin"],"security":[{"InternalToken":[]}],"summary":"Inject an inbound message into the `wa-inbound` queue (MockAdapter e2e)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["accountId","fromE164","body"],"properties":{"accountId":{"type":"string","format":"uuid"},"fromE164":{"type":"string"},"body":{"type":"string"},"isGroup":{"type":"boolean"},"isFromMe":{"type":"boolean"}}}}}},"responses":{"202":{"description":"Queued"}}}},"/admin/stats/overview":{"get":{"tags":["admin"],"security":[{"InternalToken":[]}],"summary":"Aggregate counters","responses":{"200":{"description":"Overview"}}}},"/admin/accounts":{"get":{"tags":["admin"],"security":[{"InternalToken":[]}],"summary":"WhatsApp accounts with runtime state","responses":{"200":{"description":"Accounts"}}}},"/admin/verifications":{"get":{"tags":["admin"],"security":[{"InternalToken":[]}],"summary":"Verifications (filter + pagination)","responses":{"200":{"description":"Verifications"}}}},"/admin/webhook-deliveries":{"get":{"tags":["admin"],"security":[{"InternalToken":[]}],"summary":"Webhook deliveries (filter + pagination)","responses":{"200":{"description":"Deliveries"}}}}}}