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

# Check a code

> Check the validity of a verification code.

<RequestExample>
  ```javascript Node.js theme={null}
  import Prelude from "@prelude.so/sdk";

  const client = new Prelude();

  async function main() {
    const check = await client.verification.check({
      target: {
        type: "phone_number",
        value: "+30123456789",
      },
      code: "123456",
    });

    console.log(check.id);
  }

  main();
  ```

  ```go Go theme={null}
  package main

  import (
    	"context"
    	"fmt"

    	"github.com/prelude-so/go-sdk"
    	"github.com/prelude-so/go-sdk/option"
  )

  func main() {
  	client := prelude.NewClient()

  	check, err := client.Verification.Check(context.TODO(), prelude.VerificationCheckParams{
  		Target: prelude.F(prelude.VerificationCheckParamsTarget{
  			Type:  prelude.F(prelude.VerificationCheckParamsTargetTypePhoneNumber),
  			Value: prelude.F("+30123456789"),
  		}),
  		Code: prelude.F("123456"),
  	})
  	if err != nil {
  		panic(err.Error())
  	}

  	fmt.Printf("%+v\n", check.ID)
  }
  ```

  ```python Python theme={null}
  import os
  from prelude_python_sdk import Prelude

  client = Prelude()

  check = client.verification.check(
    target={
      "type": "phone_number",
      "value": "+30123456789",
    },
    code="123456",
  )

  print(check.id)
  ```

  ```java Java theme={null}
    import so.prelude.sdk.client.PreludeClient;
    import so.prelude.sdk.client.okhttp.PreludeOkHttpClient;
    import so.prelude.sdk.models.VerificationCheckParams;
    import so.prelude.sdk.models.VerificationCheckResponse;

    // Configures using the `API_TOKEN` environment variable
    PreludeClient client = PreludeOkHttpClient.fromEnv();

    VerificationCheckParams params = VerificationCheckParams.builder()
        .target(VerificationCheckParams.Target.builder()
            .type(VerificationCheckParams.Target.Type.PHONE_NUMBER)
            .value("+30123456789")
            .build())
        .code("123456")
        .build();
    VerificationCheckResponse verification = client.verification().check(params);
  ```

  ```ruby Ruby theme={null}
  require "bundler/setup"
  require "prelude_sdk"

  prelude = PreludeSDK::Client.new(
    api_token: ENV["API_TOKEN"] # This is the default and can be omitted
  )

  check = prelude.verification
    .check(code: "12345", target: {type: "phone_number", value: "+30123456789"})
  ```
</RequestExample>


## OpenAPI

````yaml post /v2/verification/check
openapi: 3.1.0
info:
  title: Prelude API
  version: 2.0.0
  description: The Prelude API allows you to send messages to your users.
  contact:
    email: support@prelude.so
servers:
  - url: https://api.prelude.dev
    description: Production server
security:
  - apiToken: []
tags:
  - name: Notify
    description: Send transactional and marketing messages with compliance enforcement.
  - name: Transactional
    description: Send transactional messages (deprecated - use Notify API instead).
  - name: Verify
    description: Verify phone numbers.
  - name: Watch
    description: Evaluate email addresses and phone numbers for trustworthiness.
  - name: Lookup
    description: >-
      Retrieve detailed information about a phone number including carrier data,
      line type, and portability status.
paths:
  /v2/verification/check:
    post:
      tags:
        - Verify
      summary: Check a code
      description: Check the validity of a verification code.
      operationId: checkVerification
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CheckVerificationRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckVerificationResponse'
        '400':
          description: KO
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    CheckVerificationRequest:
      type: object
      properties:
        target:
          $ref: '#/components/schemas/Target'
          description: >-
            The verification target. Either a phone number or an email address.
            To use the email verification feature contact us to discuss your use
            case.
        code:
          type: string
          examples:
            - '12345'
          description: The OTP code to validate.
      required:
        - target
        - code
    CheckVerificationResponse:
      type: object
      properties:
        id:
          type: string
          examples:
            - vrf_01jc0t6fwwfgfsq1md24mhyztj
          description: The verification identifier.
        status:
          type: string
          examples:
            - success
          enum:
            - success
            - failure
            - expired_or_not_found
          description: The status of the check.
        metadata:
          type: object
          description: The metadata for this verification.
          properties:
            correlation_id:
              type: string
              description: >-
                A user-defined identifier to correlate this verification with.
                It is returned in the response and any webhook events that refer
                to this verification.
              maxLength: 80
        request_id:
          type: string
      required:
        - status
    Error:
      type: object
      properties:
        code:
          type: string
          description: The error code.
          examples:
            - invalid_phone_number
        message:
          type: string
          examples:
            - >-
              The provided phone number is invalid. Provide a valid E.164 phone
              number.
          description: A human-readable message describing the error.
        type:
          type: string
          examples:
            - bad_request
          description: The error type.
        request_id:
          type: string
          examples:
            - 3d19215e-2991-4a05-a41a-527314e6ff6a
          description: >-
            A string that identifies this specific request. Report it back to us
            to help us diagnose your issues.
      required:
        - code
        - message
        - type
    Target:
      type: object
      description: The operation target. Either a phone number or an email address.
      properties:
        type:
          type: string
          enum:
            - phone_number
            - email_address
          description: The type of the target. Either "phone_number" or "email_address".
        value:
          type: string
          examples:
            - '+30123456789'
            - mail@example.com
          description: An E.164 formatted phone number or an email address.
      required:
        - type
        - value
  securitySchemes:
    apiToken:
      type: http
      scheme: bearer

````