1 /**
2 * @oas [post] /admin/invites/accept
3 * operationId: PostInvitesAccept
4 * summary: Accept Invite
5 * description: |
6 * Accept an invite and create a new user.
7 * Since the user isn't created yet, the JWT token used in the authorization header is retrieved from the `/auth/user/emailpass/register` API route (or a provider other than `emailpass`). The user can then authenticate using the `/auth/user/emailpass` API route.
8 * x-authenticated: true
9 * requestBody:
10 * content:
11 * application/json:
12 * schema:
13 * $ref: "#/components/schemas/AdminGetInviteAcceptParams"
14 * x-codeSamples:
15 * - lang: JavaScript
16 * label: JS SDK
17 * source: |-
18 * import Medusa from "@medusajs/js-sdk"
19 *
20 * export const sdk = new Medusa({
21 * baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
22 * debug: import.meta.env.DEV,
23 * auth: {
24 * type: "session",
25 * },
26 * })
27 *
28 * await sdk.auth.register("user", "emailpass", {
29 * email: "user@gmail.com",
30 * password: "supersecret"
31 * })
32 *
33 * // all subsequent requests will use the token in the header
34 * const { user } = await sdk.admin.invite.accept(
35 * {
36 * email: "user@gmail.com",
37 * first_name: "John",
38 * last_name: "Smith",
39 * invite_token: "12345..."
40 * },
41 * )
42 * - lang: Shell
43 * label: cURL
44 * source: |-
45 * curl -X POST '{backend_url}/admin/invites/accept?token={invite_token}' \
46 * -H 'Content-Type: application/json' \
47 * --data-raw '{
48 * "email": "Lila_Zemlak@hotmail.com",
49 * "first_name": "{value}",
50 * "last_name": "{value}"
51 * }'
52 * tags:
53 * - Invites
54 * responses:
55 * "200":
56 * description: OK
57 * content:
58 * application/json:
59 * schema:
60 * oneOf:
61 * - type: object
62 * description: The created user's details.
63 * required:
64 * - user
65 * properties:
66 * user:
67 * $ref: "#/components/schemas/AdminUser"
68 * - type: object
69 * description: An error's details.
70 * required:
71 * - message
72 * properties:
73 * message:
74 * type: string
75 * title: message
76 * description: The error message.
77 * "400":
78 * $ref: "#/components/responses/400_error"
79 * "401":
80 * $ref: "#/components/responses/unauthorized"
81 * "404":
82 * $ref: "#/components/responses/not_found_error"
83 * "409":
84 * $ref: "#/components/responses/invalid_state_error"
85 * "422":
86 * $ref: "#/components/responses/invalid_request_error"
87 * "500":
88 * $ref: "#/components/responses/500_error"
89 * x-workflow: acceptInviteWorkflow
90 * security:
91 * - cookie_auth: []
92 * - jwt_token: []
93 * x-events:
94 * - name: user.created
95 * payload: |-
96 * ```ts
97 * {
98 * id, // The ID of the user
99 * }
100 * ```
101 * description: Emitted when users are created.
102 * deprecated: false
103 * - name: invite.accepted
104 * payload: |-
105 * ```ts
106 * {
107 * id, // The ID of the invite
108 * }
109 * ```
110 * description: Emitted when an invite is accepted.
111 * deprecated: false
112 * parameters:
113 * - name: token
114 * in: query
115 * description: The invite's token.
116 * required: true
117 * schema:
118 * type: string
119 * title: token
120 * description: The invite's token.
121 * - name: fields
122 * in: query
123 * description: Comma-separated fields that should be included in the returned data. If a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default
124 * fields. Without prefix it will replace the entire default fields.
125 * required: false
126 * schema:
127 * type: string
128 * title: fields
129 * description: Comma-separated fields that should be included in the returned data. If a field is prefixed with `+` it will be added to the default fields, using `-` will remove it from the default
130 * fields. Without prefix it will replace the entire default fields.
131 * externalDocs:
132 * url: "#select-fields-and-relations"
133 *
134 */
135