# Start a verification

Verify a user via Number Verify, WhatsApp OTP, Smart Verification Routing OTP, or Email OTP.

# OpenAPI definition

````json
{
  "openapi": "3.0.3",
  "info": {
    "title": "Verification Service API",
    "description": "Verification as a Service API",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.cm.com/verification-service/v1"
    }
  ],
  "security": [
    {
      "JWT": []
    }
  ],
  "tags": [
    {
      "name": "Verify",
      "description": "Verify a user"
    }
  ],
  "paths": {
    "/verify": {
      "post": {
        "summary": "Start a verification",
        "description": "Verify a user via Number Verify, WhatsApp OTP, Smart Verification Routing OTP, or Email OTP.",
        "tags": [
          "Verify"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VerificationCreateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "User verification has been created.",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/VerificationResponse"
                    }
                  ],
                  "properties": {
                    "sessionUrl": {
                      "type": "string",
                      "description": "The URL to be loaded from the mobile device connected to the mobile network. This field is not present if verification type is not silent.",
                      "nullable": true,
                      "example": "https://example.com/v1/dm/session/d635424bb0a54d388477cb17fa308655"
                    },
                    "lowConversionMode": {
                      "type": "boolean",
                      "description": "Whether the verification was created during low conversion mode. This field is not present if low conversion mode is disabled.",
                      "nullable": true,
                      "example": true
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "VerificationCreateRequest": {
        "type": "object",
        "properties": {
          "phoneNumber": {
            "type": "string",
            "description": "The phone number of the user to verify. Must be in E.164 format.",
            "example": 31612345678
          },
          "email": {
            "type": "string",
            "description": "The email address to send an Email OTP as an optional final verification failover.",
            "format": "email",
            "example": "john.doe@example.com"
          },
          "callbackUrl": {
            "type": "string",
            "description": "Updates regarding the verification will be sent to the callback URL. It must begin with `https://`.",
            "format": "url",
            "example": "https://example.com"
          },
          "excludeChannels": {
            "type": "array",
            "description": "List of channels this verification should not use in the case of OTP failover.",
            "nullable": true,
            "items": {
              "$ref": "#/components/schemas/ExcludeChannel"
            },
            "example": [
              "viber",
              "whatsapp"
            ]
          },
          "locale": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Locale"
              }
            ]
          }
        },
        "required": [
          "phoneNumber",
          "callbackUrl"
        ]
      },
      "VerificationResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique ID of the verification.",
            "format": "uuid",
            "example": "6f8d0a9d-b85c-4c3f-9e69-5699f1e00f49"
          },
          "state": {
            "type": "string",
            "description": "State of the verification.",
            "oneOf": [
              {
                "$ref": "#/components/schemas/State"
              }
            ]
          },
          "type": {
            "type": "boolean",
            "description": "Type of verification.",
            "oneOf": [
              {
                "$ref": "#/components/schemas/Type"
              }
            ]
          },
          "locale": {
            "description": "Used locale of the verification",
            "oneOf": [
              {
                "$ref": "#/components/schemas/Locale"
              }
            ]
          }
        }
      },
      "ErrorResponse": {
        "title": "Error Response",
        "type": "object",
        "properties": {
          "status": {
            "type": "integer",
            "format": "int32",
            "description": "Response status code, should match HTTP error code.",
            "example": 400
          },
          "message": {
            "type": "string",
            "description": "Description of the error that occurred.",
            "example": "The phone number field is required"
          },
          "code": {
            "$ref": "#/components/schemas/ErrorCode"
          }
        }
      },
      "State": {
        "type": "string",
        "description": "Verification state description:\n * pending - Verification is pending user or operator action\n * success - User has been successfully verified\n * failed - User has failed verification\n * expired - Verification has expired\n",
        "enum": [
          "pending",
          "success",
          "failed",
          "expired"
        ],
        "example": "success"
      },
      "Type": {
        "type": "string",
        "description": "Verification type description:\n\n * silent - Number Verify silent verification\n * whatsapp - WhatsApp OTP\n * smart - Smart Verification Routing OTP\n * voice - Voice OTP\n * email - Email OTP\n",
        "enum": [
          "silent",
          "whatsapp",
          "smart",
          "voice",
          "email"
        ],
        "example": "silent"
      },
      "ErrorCode": {
        "type": "integer",
        "description": "Error code description:\n\n * 1000 - Unknown error\n * 1001 - Invalid request\n * 2000 - Validation error\n * 2001 - Invalid `phoneNumber` field\n * 2002 - Invalid `email` field\n * 2003 - Invalid `callbackUrl` field\n * 2004 - Invalid `verificationCode` field\n * 2005 - Invalid `excludeChannels` field\n * 3000 - Verification create error\n * 3001 - Verification update error\n",
        "enum": [
          1000,
          1001,
          2000,
          2001,
          2002,
          2003,
          2004,
          2005,
          3000,
          3001
        ],
        "example": 2001
      },
      "ExcludeChannel": {
        "type": "string",
        "enum": [
          "rcs",
          "sms",
          "viber",
          "voice",
          "whatsapp"
        ],
        "description": "Possible OTP channel to exclude",
        "example": "voice"
      },
      "Locale": {
        "type": "string",
        "enum": [
          "de_DE",
          "en_GB",
          "en_US",
          "es_ES",
          "fr_FR",
          "it_IT",
          "nl_NL"
        ],
        "default": "en_GB",
        "description": "Specifies the language in which the verification message will be sent. If not specified, it defaults to English (en_GB)",
        "example": "nl_NL"
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Errors related to the request.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "status": 400,
              "message": "The phone number field is required",
              "code": 2001
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Errors related to the authorization.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "status": 401,
              "message": "Unauthorized",
              "code": 1001
            }
          }
        }
      },
      "NotFound": {
        "description": "Errors related to the request URL",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "status": 404,
              "message": "Not found",
              "code": 1000
            }
          }
        }
      },
      "InternalServerError": {
        "description": "Errors related to the verification.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "status": 500,
              "message": "Verification could not be started.",
              "code": 3000
            }
          }
        }
      }
    },
    "securitySchemes": {
      "JWT": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "In order to authenticate you need to use your credentials to generate a JWT Bearer token. The [JWT token](https://jwt.io/introduction/) has to be generated using the `HS256` algorithm and your credentials. This JWT has to contain the following attributes: `iat`, `nbf`, `exp`  in the payload, as well as the attribute `kid` in the header of the JWT. This `kid` attribute needs to contain the Key Id of your credentials.\n\nThe generated token needs to be passed via the HTTP Authorization header like:\n\n```\nAuthorization: Bearer GENERATED_TOKEN_HERE\n```\n\nThere are many libraries available for different programming languages that can help you to generate a JWT. See the Libraries tab on [https://jwt.io](https://jwt.io)\n"
      }
    }
  },
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "_id": {
    "buffer": {
      "0": 106,
      "1": 132,
      "2": 111,
      "3": 81,
      "4": 57,
      "5": 37,
      "6": 216,
      "7": 106,
      "8": 242,
      "9": 54,
      "10": 178,
      "11": 164
    }
  }
}
````