Skip to main content
POST
/
login-customer
Login or Register Customer
curl --request POST \
  --url https://api.craveup.com/api/v1/login-customer \
  --header 'Content-Type: application/json' \
  --data '
{
  "identifierString": "user@example.com",
  "customerName": "John Doe",
  "profilePicture": "https://cdn.example.com/avatar.jpg",
  "provider": "google",
  "lastName": "Doe"
}
'
import requests

url = "https://api.craveup.com/api/v1/login-customer"

payload = {
"identifierString": "user@example.com",
"customerName": "John Doe",
"profilePicture": "https://cdn.example.com/avatar.jpg",
"provider": "google",
"lastName": "Doe"
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
identifierString: 'user@example.com',
customerName: 'John Doe',
profilePicture: 'https://cdn.example.com/avatar.jpg',
provider: 'google',
lastName: 'Doe'
})
};

fetch('https://api.craveup.com/api/v1/login-customer', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.craveup.com/api/v1/login-customer",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'identifierString' => 'user@example.com',
'customerName' => 'John Doe',
'profilePicture' => 'https://cdn.example.com/avatar.jpg',
'provider' => 'google',
'lastName' => 'Doe'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.craveup.com/api/v1/login-customer"

payload := strings.NewReader("{\n \"identifierString\": \"user@example.com\",\n \"customerName\": \"John Doe\",\n \"profilePicture\": \"https://cdn.example.com/avatar.jpg\",\n \"provider\": \"google\",\n \"lastName\": \"Doe\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.craveup.com/api/v1/login-customer")
.header("Content-Type", "application/json")
.body("{\n \"identifierString\": \"user@example.com\",\n \"customerName\": \"John Doe\",\n \"profilePicture\": \"https://cdn.example.com/avatar.jpg\",\n \"provider\": \"google\",\n \"lastName\": \"Doe\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.craveup.com/api/v1/login-customer")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"identifierString\": \"user@example.com\",\n \"customerName\": \"John Doe\",\n \"profilePicture\": \"https://cdn.example.com/avatar.jpg\",\n \"provider\": \"google\",\n \"lastName\": \"Doe\"\n}"

response = http.request(request)
puts response.read_body
{
  "stytchUserId": "user-live-123",
  "methodId": "email-live-456",
  "created": true
}
{
"success": false,
"message": "Invalid input parameters",
"code": "BAD_REQUEST",
"data": {}
}
{
"success": false,
"message": "An unexpected error occurred",
"code": "GENERIC_ERROR"
}

Body

application/json
identifierString
string
required
Example:

"user@example.com"

customerName
string
required
Example:

"John Doe"

profilePicture
string | null
Example:

"https://cdn.example.com/avatar.jpg"

provider
string | null
Example:

"google"

lastName
string | null
Example:

"Doe"

Response

OTP challenge initiated successfully.

Response returned by Stytch when an OTP challenge is initiated. Use methodId when submitting the OTP.

stytchUserId
string
required
Example:

"user-live-123"

methodId
string
required
Example:

"email-live-456"

created
boolean
required
Example:

true