Import customers
POST
/api/customers/import
const url = 'https://example.com/api/customers/import';const options = { method: 'POST', headers: { cookie: 'better-auth.session_token=<better-auth.session_token>', 'Content-Type': 'application/json' }, body: '{"content":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/api/customers/import \ --header 'Content-Type: application/json' \ --cookie better-auth.session_token=<better-auth.session_token> \ --data '{ "content": "example" }'Admin only. Requires an authenticated session with the admin role.
Authorizations
Section titled “ Authorizations ”Request Bodyrequired
Section titled “ Request Bodyrequired ”CSV file contents to parse and upsert.
Media typeapplication/json
CSV file contents for customer import.
object
content
required
string
Examplegenerated
{ "content": "example"}Responses
Section titled “ Responses ”Number of customers imported.
Media typeapplication/json
object
count
required
integer
errors
required
Array<object>
object
index
integer
name
string
message
required
string
Examplegenerated
{ "count": 1, "errors": [ { "index": 1, "name": "example", "message": "example" } ]}The import body was invalid.
Media typeapplication/json
object
error
required
string
errors
Array<object>
object
index
integer
name
string
message
required
string
Examplegenerated
{ "error": "example", "errors": [ { "index": 1, "name": "example", "message": "example" } ]}No valid Better Auth session was present.
Media typeapplication/json
Returned when no valid Better Auth session is present.
object
error
required
string
Examplegenerated
{ "error": "example"}The import failed while writing customers.
Media typeapplication/json
object
error
required
string
errors
Array<object>
object
index
integer
name
string
message
required
string
Examplegenerated
{ "error": "example", "errors": [ { "index": 1, "name": "example", "message": "example" } ]}
