> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xtremepush.com/llms.txt
> Use this file to discover all available pages before exploring further.

# OTP Execute

> Used to send pre-generated one-time passwords (OTPs) to your users.

<br>
Send pre-generated one-time passwords (OTP) to your customers using Xtremepush's SMS delivery functionality. The OTP is placed in a dedicated queue to ensure it is sent to your user immediately. You can send one OTP to one recipient per API request.

Each successful OTP request returns a unique OTP ID in the API response.

<br>

For each request, a new record is created in the <strong>History</strong> tab of your OTP integration, which logs the delivery status, request date, and other relevant details.

<br>

The request body must be a JSON object containing the pre-generated OTP code and the user identification details. The structure of the request body differs depending on whether you identify the user by their ID (customer, profile or user ID) or their mobile number as shown in the examples below.

## OpenAPI

````json POST /otp/execute
{
  "openapi": "3.1.0",
  "info": {
    "title": "external-api",
    "version": "1"
  },
  "servers": [
    {
      "url": "https://api.eu.xtremepush.com/api/external"
    }
  ],
  "paths": {
    "/otp/execute": {
      "post": {
        "summary": "OTP Execute",
        "description": "Used to send pre-generated one-time passwords (OTPs) to your users.\n\n<br>\nSend pre-generated one-time passwords (OTP) to your customers using Xtremepush's SMS delivery functionality. The OTP is placed in a dedicated queue to ensure it is sent to your user immediately. You can send one OTP to one recipient per API request.\n\nEach successful OTP request returns a unique OTP ID in the API response.\n\n<br>\n\nFor each request, a new record is created in the <strong>History</strong> tab of your OTP integration, which logs the delivery status, request date, and other relevant details.\n\n<br>\n\nThe request body must be a JSON object containing the pre-generated OTP code and the user identification details. The structure of the request body differs depending on whether you identify the user by their ID (customer, profile or user ID) or their mobile number as shown in the examples below.",
        "operationId": "otp-execute",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "apptoken",
                  "id",
                  "id_type",
                  "service_id",
                  "mobile_number",
                  "send_by",
                  "otp_code",
                  "channel"
                ],
                "properties": {
                  "apptoken": {
                    "type": "string",
                    "description": "Your App token"
                  },
                  "id": {
                    "type": "string",
                    "description": "Identifier of the user profile. Required only if you're specifying the recipient using customer, profile, or user ID"
                  },
                  "id_type": {
                    "type": "string",
                    "description": "Specify if the ID is a **user_id**, **profile_id**, or **customer_id**"
                  },
                  "service_id": {
                    "type": "string",
                    "description": "Your OTP integration ID. The associated OTP integration must be active."
                  },
                  "mobile_number": {
                    "type": "string",
                    "description": "The mobile number to which the OTP must be delivered. Required only if you're specifying the recipient using a mobile number."
                  },
                  "send_by": {
                    "type": "string",
                    "description": "Determines how the profile is identified for OTP delivery. Choose **id** if the profile is identified using an ID, or **contact** if using a phone number"
                  },
                  "otp_code": {
                    "type": "string",
                    "description": "The pre-generated OTP code you want to send to your user. The OTP must be alphanumeric and between 4 to 10 characters in length"
                  },
                  "channel": {
                    "type": "string",
                    "description": "Specify **sms** as the delivery channel for your OTP"
                  }
                }
              },
              "examples": {
                "Specify Recipient using User ID": {
                  "value": {
                    "apptoken": "YOUR_APPTOKEN",
                    "service_id": "YOUR_SERVICE_ID",
                    "send_by": "id",
                    "id": "USER_ID",
                    "id_type": "user_id",
                    "otp_code": "123456",
                    "channel": "sms"
                  }
                },
                "Specify Recipient using Mobile Number": {
                  "value": {
                    "apptoken": "YOUR_APPTOKEN",
                    "service_id": "YOUR_SERVICE_ID",
                    "send_by": "contact",
                    "mobile_number": "+353850123456",
                    "otp_code": "123456",
                    "channel": "sms"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "requestID": {
                      "type": "string",
                      "example": "<otp_id>"
                    },
                    "code": {
                      "type": "string",
                      "example": "Success"
                    }
                  }
                },
                "examples": {
                  "Result": {
                    "value": {
                      "requestID": "<otp_id>",
                      "code": "Success"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "400",
            "content": {
              "application/json": {}
            }
          },
          "401": {
            "description": "401",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": "false",
                      "default": "true"
                    },
                    "code": {
                      "type": "integer",
                      "example": "401",
                      "default": "0"
                    },
                    "message": {
                      "type": "string",
                      "example": "Unauthorized"
                    }
                  }
                },
                "examples": {
                  "Result": {
                    "value": {
                      "success": "false",
                      "code": "401",
                      "message": "Unauthorized"
                    }
                  }
                }
              }
            }
          }
        },
        "tags": [
          "OTP Methods"
        ]
      }
    }
  }
}
````

