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

# Check verification

> Checks the code against a verification.



## OpenAPI

````yaml POST /verifications/{id}/checks
openapi: 3.1.1
info:
  title: Surge
  version: '1.0'
servers:
  - url: https://api.surge.app
security:
  - authorization: []
paths:
  /verifications/{id}/checks:
    post:
      tags:
        - Verifications
      summary: Check a verification
      description: Checks the code against a verification.
      operationId: CheckVerification
      parameters:
        - in: path
          name: id
          required: true
          schema:
            description: The ID of the verification to check against.
            example: vfn_01jayh15c2f2xamftg0xpyq1nj
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VerificationCheckParams'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VerificationCheck'
          description: Correct code
        '409':
          content:
            application/json:
              examples:
                Already verified:
                  value:
                    result: already_verified
              schema:
                $ref: '#/components/schemas/VerificationCheck'
          description: Already verified
        '422':
          content:
            application/json:
              examples:
                Exhausted:
                  value:
                    result: incorrect
                    verification:
                      attempt_count: 3
                      id: vfn_01jayh15c2f2xamftg0xpyq1nj
                      phone_number: '+18015551234'
                      status: exhausted
                Expired:
                  value:
                    result: expired
                    verification:
                      attempt_count: 0
                      id: vfn_01jayh15c2f2xamftg0xpyq1nj
                      phone_number: '+18015551234'
                      status: expired
                Incorrect:
                  value:
                    result: incorrect
                    verification:
                      attempt_count: 1
                      id: vfn_01jayh15c2f2xamftg0xpyq1nj
                      phone_number: '+18015551234'
                      status: pending
              schema:
                $ref: '#/components/schemas/VerificationCheck'
          description: Check failed
        default:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Error
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Surge from '@surgeapi/node';


            const client = new Surge({
              apiKey: process.env['SURGE_API_KEY'], // This is the default and can be omitted
            });


            const verificationCheck = await
            client.verifications.check('vfn_01jayh15c2f2xamftg0xpyq1nj', {
              code: '123456',
            });


            console.log(verificationCheck.result);
        - lang: Python
          source: |-
            import os
            from surge import Surge

            client = Surge(
                api_key=os.environ.get("SURGE_API_KEY"),  # This is the default and can be omitted
            )
            verification_check = client.verifications.check(
                id="vfn_01jayh15c2f2xamftg0xpyq1nj",
                code="123456",
            )
            print(verification_check.result)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/stainless-sdks/surge-go\"\n\t\"github.com/stainless-sdks/surge-go/option\"\n)\n\nfunc main() {\n\tclient := surge.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tverificationCheck, err := client.Verifications.Check(\n\t\tcontext.TODO(),\n\t\t\"vfn_01jayh15c2f2xamftg0xpyq1nj\",\n\t\tsurge.VerificationCheckParams{\n\t\t\tCode: \"123456\",\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", verificationCheck.Result)\n}\n"
        - lang: Ruby
          source: >-
            require "surge_api"


            surge = SurgeAPI::Client.new(api_key: "My API Key")


            verification_check =
            surge.verifications.check("vfn_01jayh15c2f2xamftg0xpyq1nj", code:
            "123456")


            puts(verification_check)
        - lang: PHP
          source: >-
            <?php


            require_once dirname(__DIR__) . '/vendor/autoload.php';


            use Surge\Client;

            use Surge\Core\Exceptions\APIException;


            $client = new Client(apiKey: getenv('SURGE_API_KEY') ?: 'My API
            Key');


            try {
              $verificationCheck = $client->verifications->check(
                'vfn_01jayh15c2f2xamftg0xpyq1nj', code: '123456'
              );

              var_dump($verificationCheck);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
components:
  schemas:
    VerificationCheckParams:
      description: Parameters for checking a Verification code
      example:
        code: '123456'
      properties:
        code:
          description: The Verification code that was received.
          example: '123456'
          pattern: ^[0-9]{6}$
          type: string
      required:
        - code
      title: VerificationCheckParams
      type: object
    VerificationCheck:
      description: The result of checking a Verification code
      example:
        result: ok
        verification:
          attempt_count: 1
          id: vfn_01jayh15c2f2xamftg0xpyq1nj
          phone_number: '+18015551234'
          status: verified
      properties:
        result:
          description: The result of the code check.
          enum:
            - ok
            - incorrect
            - exhausted
            - expired
            - already_verified
          type: string
        verification:
          $ref: '#/components/schemas/Verification'
      title: VerificationCheck
      type: object
    ErrorResponse:
      description: An error response
      example:
        error:
          message: The requested resource could not be found.
          type: not_found
      properties:
        error:
          $ref: '#/components/schemas/Error'
      required:
        - error
      title: ErrorResponse
      type: object
    Verification:
      description: A phone number verification
      example:
        attempt_count: 0
        id: vfn_01jayh15c2f2xamftg0xpyq1nj
        phone_number: '+18015551234'
        status: pending
      properties:
        attempt_count:
          description: The number of times the code has been attempted.
          type: integer
        id:
          description: Unique identifier for the object.
          type: string
        phone_number:
          description: The phone number being verified. In E.164 format.
          example: '+18015551234'
          format: phone-number
          pattern: ^\+[1-9]\d{6,14}$
          type: string
        status:
          description: The current status of the verification.
          enum:
            - pending
            - verified
            - exhausted
            - expired
          type: string
      required:
        - id
        - attempt_count
        - phone_number
        - status
      title: Verification
      type: object
    Error:
      description: An error response
      example:
        message: The requested resource was not found.
        type: not_found
      properties:
        detail:
          additionalProperties: true
          description: Additional details about the error.
          type: object
        message:
          description: A human-readable error message.
          example: The requested resource was not found.
          type: string
        type:
          description: A unique error code.
          example: not_found
          type: string
      required:
        - type
        - message
      title: Error
      type: object
  securitySchemes:
    authorization:
      bearerFormat: Surge API token
      scheme: bearer
      type: http

````