POST
/
auth
/
customer
/
{auth_provider}
/
register
import Medusa from "@medusajs/js-sdk"

let MEDUSA_BACKEND_URL = "http://localhost:9000"

if (process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL) {
  MEDUSA_BACKEND_URL = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL
}

export const sdk = new Medusa({
  baseUrl: MEDUSA_BACKEND_URL,
  debug: process.env.NODE_ENV === "development",
  publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
})

await sdk.auth.register(
  "customer",
  "emailpass",
  {
    email: "customer@gmail.com",
    password: "supersecret"
  }
)

// all subsequent requests will use the token in the header
const { customer } = await sdk.store.customer.create({
  email: "customer@gmail.com",
  password: "supersecret"
})
{
"token": "<string>"
}

Path Parameters

auth_provider
string
required

The provider used for authentication.

Example:

"emailpass"

Body

application/json · input · object

The input data necessary for authentication. For example, for email-pass authentication, pass email and password properties.

Response

200
application/json

OK

The authentication's details.