1 post:
2 operationId: PostVerificationRequest
3 summary: Request Customer Verification
4 x-sidebar-summary: Request Verification
5 description: >-
6 Create a verification request for a customer. This API route is used when a
7 customer logs in, but their email requires verification. It can also be used
8 for custom flows, such as phone number verification. Once successfully
9 requested, a verification code will be generated and an
10 `auth.verification_requested` event will be emitted. You can listen to this
11 event and decide how to deliver the code to the customer.
12 externalDocs:
13 url: >-
14 https://docs.medusajs.com/resources/storefront-development/customers/verify-account
15 description: 'Storefront guide: Register Customer with Email Verification.'
16 x-authenticated: false
17 parameters: []
18 requestBody:
19 content:
20 application/json:
21 schema:
22 type: object
23 description: The verification request details
24 required:
25 - entity_id
26 - entity_type
27 - code_provider
28 properties:
29 entity_id:
30 type: string
31 title: entity_id
32 description: >-
33 The identifier of the user or customer. For example, an email
34 address.
35 entity_type:
36 type: string
37 title: entity_type
38 description: >-
39 The type of identity being verified. For example, "email" or
40 "phone_number".
41 code_provider:
42 type: string
43 title: code_provider
44 description: >-
45 The provider to use to create the verification token or code. By
46 default, Medusa provides a `token` provider that generates a
47 random token. You can also implement your own provider to
48 generate a code or OTP.
49 metadata:
50 type: object
51 description: >-
52 Custom key-value pairs that can be passed to the verification
53 request. This is optional and can be used to store additional
54 information related to the verification request.
55 x-codeSamples:
56 - lang: Shell
57 label: cURL
58 source:
59 $ref: ../code_samples/Shell/auth_verification_request/post.sh
60 tags:
61 - Auth
62 responses:
63 '201':
64 description: OK
65 '400':
66 $ref: ../components/responses/400_error.yaml
67 '401':
68 $ref: ../components/responses/unauthorized.yaml
69 '404':
70 $ref: ../components/responses/not_found_error.yaml
71 '409':
72 $ref: ../components/responses/invalid_state_error.yaml
73 '422':
74 $ref: ../components/responses/invalid_request_error.yaml
75 '500':
76 $ref: ../components/responses/500_error.yaml
77 x-workflow: requestVerificationWorkflow
78 x-events:
79 - name: auth.verification_requested
80 payload: |-
81 ```ts
82 {
83 entity_id, // The identifier of the entity being verified. For example, an email address.
84 entity_type, // The kind of entity being verified. For example, "email".
85 code_provider, // The verification provider that generated the code. For example, "token".
86 auth_identity_id, // The ID of the auth identity being verified.
87 code, // The generated verification code.
88 expires_at, // (Date) The code expiry date.
89 metadata, // (object) Optional custom metadata passed from the request.
90 }
91 ```
92 description: >-
93 Emitted when a verification code is generated. You can listen to
94
95 this event and decide how to deliver the code to the user or customer.
96
97 The payload changed in v2.17.0:
98
99 `actor_type` and `provider_identity_id` were removed,
100
101 `provider` was renamed to `code_provider`, and `entity_type` was added.
102
103 Subscribers written before v2.17.0 must be updated to use the payload
104 below.
105 deprecated: false
106 since: 2.15.5
107 x-since: 2.16.0