1 /**
2 * @oas [post] /admin/customers/{id}
3 * operationId: PostCustomersId
4 * summary: Update a Customer
5 * description: Update a customer's details.
6 * x-authenticated: true
7 * parameters:
8 * - name: id
9 * in: path
10 * description: The customer's ID.
11 * required: true
12 * schema:
13 * type: string
14 * - name: fields
15 * in: query
16 * 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
17 * fields. without prefix it will replace the entire default fields. This API route restricts the fields that can be selected. Learn how to override the retrievable fields in the [Retrieve Custom
18 * Links](https://docs.medusajs.com/learn/fundamentals/api-routes/retrieve-custom-links) documentation.
19 * required: false
20 * schema:
21 * type: string
22 * title: fields
23 * 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
24 * fields. without prefix it will replace the entire default fields. This API route restricts the fields that can be selected. Learn how to override the retrievable fields in the [Retrieve Custom
25 * Links](https://docs.medusajs.com/learn/fundamentals/api-routes/retrieve-custom-links) documentation.
26 * externalDocs:
27 * url: "#select-fields-and-relations"
28 * security:
29 * - api_token: []
30 * - cookie_auth: []
31 * - jwt_token: []
32 * requestBody:
33 * content:
34 * application/json:
35 * schema:
36 * allOf:
37 * - type: object
38 * description: The customer's details.
39 * required:
40 * - email
41 * - company_name
42 * - first_name
43 * - last_name
44 * - phone
45 * - metadata
46 * properties:
47 * email:
48 * type: string
49 * title: email
50 * description: The customer's email.
51 * format: email
52 * company_name:
53 * type: string
54 * title: company_name
55 * description: The customer's company name.
56 * first_name:
57 * type: string
58 * title: first_name
59 * description: The customer's first name.
60 * last_name:
61 * type: string
62 * title: last_name
63 * description: The customer's last name.
64 * phone:
65 * type: string
66 * title: phone
67 * description: The customer's phone.
68 * metadata:
69 * type: object
70 * description: The customer's metadata.
71 * - type: object
72 * description: The customer's details.
73 * properties:
74 * additional_data:
75 * type: object
76 * description: Pass additional custom data to the API route. This data is passed to the underlying workflow under the `additional_data` parameter.
77 * description: The customer's details.
78 * x-codeSamples:
79 * - lang: JavaScript
80 * label: JS SDK
81 * source: |-
82 * import Medusa from "@medusajs/js-sdk"
83 *
84 * export const sdk = new Medusa({
85 * baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
86 * debug: import.meta.env.DEV,
87 * auth: {
88 * type: "session",
89 * },
90 * })
91 *
92 * sdk.admin.customer.update("cus_123", {
93 * first_name: "John"
94 * })
95 * .then(({ customer }) => {
96 * console.log(customer)
97 * })
98 * - lang: Shell
99 * label: cURL
100 * source: |-
101 * curl -X POST '{backend_url}/admin/customers/{id}' \
102 * -H 'Authorization: Bearer {jwt_token}' \
103 * -H 'Content-Type: application/json' \
104 * --data-raw '{
105 * "email": "Daren_Rodriguez-Rutherford93@gmail.com",
106 * "company_name": "{value}",
107 * "first_name": "{value}",
108 * "last_name": "{value}",
109 * "phone": "{value}",
110 * "metadata": {}
111 * }'
112 * tags:
113 * - Customers
114 * responses:
115 * "200":
116 * description: OK
117 * content:
118 * application/json:
119 * schema:
120 * $ref: "#/components/schemas/AdminCustomerResponse"
121 * "400":
122 * $ref: "#/components/responses/400_error"
123 * "401":
124 * $ref: "#/components/responses/unauthorized"
125 * "404":
126 * $ref: "#/components/responses/not_found_error"
127 * "409":
128 * $ref: "#/components/responses/invalid_state_error"
129 * "422":
130 * $ref: "#/components/responses/invalid_request_error"
131 * "500":
132 * $ref: "#/components/responses/500_error"
133 * x-workflow: updateCustomersWorkflow
134 * x-events:
135 * - name: customer.updated
136 * payload: |-
137 * ```ts
138 * {
139 * id, // The ID of the customer
140 * }
141 * ```
142 * description: Emitted when a customer is updated.
143 * deprecated: false
144 *
145 */
146