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