Raw
1 get:
2 operationId: GetCustomersId
3 summary: Get a Customer
4 description: >-
5 Retrieve a customer by its ID. You can expand the customer's relations or
6 select the fields that should be returned.
7 x-authenticated: true
8 parameters:
9 - name: id
10 in: path
11 description: The customer's ID.
12 required: true
13 schema:
14 type: string
15 - name: fields
16 in: query
17 description: >-
18 Comma-separated fields that should be included in the returned data. if
19 a field is prefixed with `+` it will be added to the default fields,
20 using `-` will remove it from the default fields. without prefix it will
21 replace the entire default fields. This API route restricts the fields
22 that can be selected. Learn how to override the retrievable fields in
23 the [Retrieve Custom
24 Links](https://docs.medusajs.com/learn/fundamentals/api-routes/retrieve-custom-links)
25 documentation.
26 required: false
27 schema:
28 type: string
29 title: fields
30 description: >-
31 Comma-separated fields that should be included in the returned data.
32 if a field is prefixed with `+` it will be added to the default
33 fields, using `-` will remove it from the default fields. without
34 prefix it will replace the entire default fields. This API route
35 restricts the fields that can be selected. Learn how to override the
36 retrievable fields in the [Retrieve Custom
37 Links](https://docs.medusajs.com/learn/fundamentals/api-routes/retrieve-custom-links)
38 documentation.
39 externalDocs:
40 url: '#select-fields-and-relations'
41 security:
42 - api_token: []
43 - cookie_auth: []
44 - jwt_token: []
45 x-codeSamples:
46 - lang: JavaScript
47 label: JS SDK
48 source:
49 $ref: ../code_samples/JavaScript/admin_customers_{id}/get.js
50 - lang: Shell
51 label: cURL
52 source:
53 $ref: ../code_samples/Shell/admin_customers_{id}/get.sh
54 tags:
55 - Customers
56 responses:
57 '200':
58 description: OK
59 content:
60 application/json:
61 schema:
62 $ref: ../components/schemas/AdminCustomerResponse.yaml
63 '400':
64 $ref: ../components/responses/400_error.yaml
65 '401':
66 $ref: ../components/responses/unauthorized.yaml
67 '404':
68 $ref: ../components/responses/not_found_error.yaml
69 '409':
70 $ref: ../components/responses/invalid_state_error.yaml
71 '422':
72 $ref: ../components/responses/invalid_request_error.yaml
73 '500':
74 $ref: ../components/responses/500_error.yaml
75 post:
76 operationId: PostCustomersId
77 summary: Update a Customer
78 description: Update a customer's details.
79 x-authenticated: true
80 parameters:
81 - name: id
82 in: path
83 description: The customer's ID.
84 required: true
85 schema:
86 type: string
87 - name: fields
88 in: query
89 description: >-
90 Comma-separated fields that should be included in the returned data. if
91 a field is prefixed with `+` it will be added to the default fields,
92 using `-` will remove it from the default fields. without prefix it will
93 replace the entire default fields. This API route restricts the fields
94 that can be selected. Learn how to override the retrievable fields in
95 the [Retrieve Custom
96 Links](https://docs.medusajs.com/learn/fundamentals/api-routes/retrieve-custom-links)
97 documentation.
98 required: false
99 schema:
100 type: string
101 title: fields
102 description: >-
103 Comma-separated fields that should be included in the returned data.
104 if a field is prefixed with `+` it will be added to the default
105 fields, using `-` will remove it from the default fields. without
106 prefix it will replace the entire default fields. This API route
107 restricts the fields that can be selected. Learn how to override the
108 retrievable fields in the [Retrieve Custom
109 Links](https://docs.medusajs.com/learn/fundamentals/api-routes/retrieve-custom-links)
110 documentation.
111 externalDocs:
112 url: '#select-fields-and-relations'
113 security:
114 - api_token: []
115 - cookie_auth: []
116 - jwt_token: []
117 requestBody:
118 content:
119 application/json:
120 schema:
121 allOf:
122 - type: object
123 description: The customer's details.
124 required:
125 - email
126 - company_name
127 - first_name
128 - last_name
129 - phone
130 - metadata
131 properties:
132 email:
133 type: string
134 title: email
135 description: The customer's email.
136 format: email
137 company_name:
138 type: string
139 title: company_name
140 description: The customer's company name.
141 first_name:
142 type: string
143 title: first_name
144 description: The customer's first name.
145 last_name:
146 type: string
147 title: last_name
148 description: The customer's last name.
149 phone:
150 type: string
151 title: phone
152 description: The customer's phone.
153 metadata:
154 type: object
155 description: The customer's metadata.
156 - type: object
157 description: The customer's details.
158 properties:
159 additional_data:
160 type: object
161 description: >-
162 Pass additional custom data to the API route. This data is
163 passed to the underlying workflow under the
164 `additional_data` parameter.
165 description: The customer's details.
166 x-codeSamples:
167 - lang: JavaScript
168 label: JS SDK
169 source:
170 $ref: ../code_samples/JavaScript/admin_customers_{id}/post.js
171 - lang: Shell
172 label: cURL
173 source:
174 $ref: ../code_samples/Shell/admin_customers_{id}/post.sh
175 tags:
176 - Customers
177 responses:
178 '200':
179 description: OK
180 content:
181 application/json:
182 schema:
183 $ref: ../components/schemas/AdminCustomerResponse.yaml
184 '400':
185 $ref: ../components/responses/400_error.yaml
186 '401':
187 $ref: ../components/responses/unauthorized.yaml
188 '404':
189 $ref: ../components/responses/not_found_error.yaml
190 '409':
191 $ref: ../components/responses/invalid_state_error.yaml
192 '422':
193 $ref: ../components/responses/invalid_request_error.yaml
194 '500':
195 $ref: ../components/responses/500_error.yaml
196 x-workflow: updateCustomersWorkflow
197 x-events:
198 - name: customer.updated
199 payload: |-
200 ```ts
201 {
202 id, // The ID of the customer
203 }
204 ```
205 description: Emitted when a customer is updated.
206 deprecated: false
207 delete:
208 operationId: DeleteCustomersId
209 summary: Delete a Customer
210 description: Delete a customer.
211 x-authenticated: true
212 parameters:
213 - name: id
214 in: path
215 description: The customer's ID.
216 required: true
217 schema:
218 type: string
219 security:
220 - api_token: []
221 - cookie_auth: []
222 - jwt_token: []
223 x-codeSamples:
224 - lang: JavaScript
225 label: JS SDK
226 source:
227 $ref: ../code_samples/JavaScript/admin_customers_{id}/delete.js
228 - lang: Shell
229 label: cURL
230 source:
231 $ref: ../code_samples/Shell/admin_customers_{id}/delete.sh
232 tags:
233 - Customers
234 responses:
235 '200':
236 description: OK
237 content:
238 application/json:
239 schema:
240 type: object
241 description: The deletion's details.
242 required:
243 - id
244 - object
245 - deleted
246 properties:
247 id:
248 type: string
249 title: id
250 description: The customer's ID.
251 object:
252 type: string
253 title: object
254 description: The customer's object.
255 deleted:
256 type: boolean
257 title: deleted
258 description: The customer's deleted.
259 '400':
260 $ref: ../components/responses/400_error.yaml
261 '401':
262 $ref: ../components/responses/unauthorized.yaml
263 '404':
264 $ref: ../components/responses/not_found_error.yaml
265 '409':
266 $ref: ../components/responses/invalid_state_error.yaml
267 '422':
268 $ref: ../components/responses/invalid_request_error.yaml
269 '500':
270 $ref: ../components/responses/500_error.yaml
271 x-workflow: removeCustomerAccountWorkflow
272 x-events:
273 - name: customer.deleted
274 payload: |-
275 ```ts
276 {
277 id, // The ID of the customer
278 }
279 ```
280 description: Emitted when a customer is deleted.
281 deprecated: false