feat(api): add phone number registration endpoint and update related logic
This commit is contained in:
@@ -76,7 +76,8 @@
|
||||
"properties": {
|
||||
"phone_number_id": { "type": "string" },
|
||||
"access_token": { "type": "string" },
|
||||
"business_account_id": { "type": "string" },
|
||||
"waba_id": { "type": "string", "description": "WhatsApp Business Account ID — resolved automatically at connect time from business_account_id if not set" },
|
||||
"business_account_id": { "type": "string", "description": "Facebook Business Manager ID — used to resolve waba_id on first connect" },
|
||||
"api_version": { "type": "string", "default": "v21.0" },
|
||||
"webhook_path": { "type": "string" },
|
||||
"verify_token": { "type": "string" }
|
||||
@@ -1246,15 +1247,15 @@
|
||||
"account_id": { "type": "string" },
|
||||
"phone_number_id": { "type": "string" },
|
||||
"code_method": { "type": "string", "enum": ["SMS", "VOICE"] },
|
||||
"language": { "type": "string" }
|
||||
"language": { "type": "string", "pattern": "^[a-z]{2,3}(_[A-Z]{2})?$", "default": "en_US", "example": "en_US", "description": "BCP-47 locale e.g. en_US, pt_BR — defaults to en_US if omitted or invalid" }
|
||||
},
|
||||
"required": ["account_id", "phone_number_id", "code_method", "language"]
|
||||
"required": ["account_id", "phone_number_id", "code_method"]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": { "description": "Verification code requested", "content": { "application/json": { "schema": { "type": "object" } } } },
|
||||
"200": { "description": "Verification code requested", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/StatusOk" } } } },
|
||||
"400": { "description": "Bad request" },
|
||||
"401": { "description": "Unauthorized" },
|
||||
"500": { "description": "Meta API error" }
|
||||
@@ -1263,7 +1264,7 @@
|
||||
},
|
||||
"/api/phone-numbers/verify-code": {
|
||||
"post": {
|
||||
"summary": "Verify a phone number with the received code (Business API only)",
|
||||
"summary": "Verify a phone number with the received OTP code (Business API only)",
|
||||
"operationId": "verifyCode",
|
||||
"tags": ["Phone Numbers"],
|
||||
"requestBody": {
|
||||
@@ -1275,7 +1276,7 @@
|
||||
"properties": {
|
||||
"account_id": { "type": "string" },
|
||||
"phone_number_id": { "type": "string" },
|
||||
"code": { "type": "string" }
|
||||
"code": { "type": "string", "pattern": "^\\d{4,8}$", "example": "123456", "description": "4–8 digit OTP received via SMS or VOICE" }
|
||||
},
|
||||
"required": ["account_id", "phone_number_id", "code"]
|
||||
}
|
||||
@@ -1283,8 +1284,37 @@
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": { "description": "Code verified", "content": { "application/json": { "schema": { "type": "object" } } } },
|
||||
"400": { "description": "Bad request" },
|
||||
"200": { "description": "Code verified", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/StatusOk" } } } },
|
||||
"400": { "description": "Bad request / invalid code format" },
|
||||
"401": { "description": "Unauthorized" },
|
||||
"500": { "description": "Meta API error" }
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/phone-numbers/register": {
|
||||
"post": {
|
||||
"summary": "Register a phone number with the WhatsApp Cloud API (Business API only)",
|
||||
"operationId": "registerPhoneNumber",
|
||||
"tags": ["Phone Numbers"],
|
||||
"requestBody": {
|
||||
"required": true,
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"account_id": { "type": "string" },
|
||||
"phone_number_id": { "type": "string" },
|
||||
"pin": { "type": "string", "pattern": "^\\d{4,8}$", "example": "123456", "description": "Two-step verification PIN (4–8 digits)" }
|
||||
},
|
||||
"required": ["account_id", "phone_number_id", "pin"]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"responses": {
|
||||
"200": { "description": "Phone number registered", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/StatusOk" } } } },
|
||||
"400": { "description": "Bad request / invalid PIN format" },
|
||||
"401": { "description": "Unauthorized" },
|
||||
"500": { "description": "Meta API error" }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user