1 post:
2 operationId: PostCustomers
3 summary: Register Customer
4 description: >-
5 Register a customer. Use the `/auth/customer/emailpass/register` API route
6 first to retrieve the registration token and pass it in the header of the
7 request.
8 externalDocs:
9 url: >-
10 https://docs.medusajs.com/resources/storefront-development/customers/register
11 description: 'Storefront guide: How to register a customer.'
12 x-authenticated: true
13 parameters:
14 - name: x-publishable-api-key
15 in: header
16 description: Publishable API Key created in the Medusa Admin.
17 required: true
18 schema:
19 type: string
20 externalDocs:
21 url: https://docs.medusajs.com/api/store#publishable-api-key
22 - name: x-medusa-locale
23 in: header
24 description: The locale in BCP 47 format to retrieve localized content.
25 required: false
26 schema:
27 type: string
28 example: en-US
29 externalDocs:
30 url: >-
31 https://docs.medusajs.com/resources/commerce-modules/translation/storefront
32 description: Learn more in the Serve Translations in Storefront guide.
33 - name: fields
34 in: query
35 description: >-
36 Comma-separated fields that should be included in the returned data. if
37 a field is prefixed with `+` it will be added to the default fields,
38 using `-` will remove it from the default fields. without prefix it will
39 replace the entire default fields.
40 required: false
41 schema:
42 type: string
43 title: fields
44 description: >-
45 Comma-separated fields that should be included in the returned data.
46 if a field is prefixed with `+` it will be added to the default
47 fields, using `-` will remove it from the default fields. without
48 prefix it will replace the entire default fields. This API route
49 restricts the fields that can be selected. Learn how to override the
50 retrievable fields in the [Retrieve Custom
51 Links](https://docs.medusajs.com/learn/fundamentals/api-routes/retrieve-custom-links)
52 documentation.
53 externalDocs:
54 url: '#select-fields-and-relations'
55 - name: locale
56 in: query
57 description: The locale in BCP 47 format to retrieve localized content.
58 required: false
59 schema:
60 type: string
61 example: en-US
62 externalDocs:
63 url: >-
64 https://docs.medusajs.com/resources/commerce-modules/translation/storefront
65 description: Learn more in the Serve Translations in Storefront guide.
66 requestBody:
67 content:
68 application/json:
69 schema:
70 $ref: ../components/schemas/StoreCreateCustomer.yaml
71 x-codeSamples:
72 - lang: JavaScript
73 label: JS SDK
74 source:
75 $ref: ../code_samples/JavaScript/store_customers/post.js
76 - lang: Shell
77 label: cURL
78 source:
79 $ref: ../code_samples/Shell/store_customers/post.sh
80 tags:
81 - Customers
82 responses:
83 '200':
84 description: OK
85 content:
86 application/json:
87 schema:
88 $ref: ../components/schemas/StoreCustomerResponse.yaml
89 '400':
90 $ref: ../components/responses/400_error.yaml
91 '401':
92 $ref: ../components/responses/unauthorized.yaml
93 '404':
94 $ref: ../components/responses/not_found_error.yaml
95 '409':
96 $ref: ../components/responses/invalid_state_error.yaml
97 '422':
98 $ref: ../components/responses/invalid_request_error.yaml
99 '500':
100 $ref: ../components/responses/500_error.yaml
101 x-workflow: createCustomerAccountWorkflow
102 security:
103 - cookie_auth: []
104 - jwt_token: []
105 x-events:
106 - name: customer.created
107 payload: |-
108 ```ts
109 {
110 id, // The ID of the customer
111 }
112 ```
113 description: Emitted when a customer is created.
114 deprecated: false
115 x-allowed:
116 - id
117 - email
118 - company_name
119 - first_name
120 - last_name
121 - phone
122 - metadata
123 - has_account
124 - deleted_at
125 - created_at
126 - updated_at
127 - addresses
128 - orders
129 - addresses.id
130 - addresses.address_name
131 - addresses.company
132 - addresses.customer_id
133 - addresses.first_name
134 - addresses.last_name
135 - addresses.address_1
136 - addresses.address_2
137 - addresses.city
138 - addresses.province
139 - addresses.postal_code
140 - addresses.country_code
141 - addresses.phone
142 - addresses.metadata
143 - addresses.is_default_shipping
144 - addresses.is_default_billing
145 - addresses.created_at
146 - addresses.updated_at