Set Password
curl --request POST \
--url https://api.sublay.io/api/v6/:projectId/api/v7/auth/set-password \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"newPassword": "<string>"
}
'import requests
url = "https://api.sublay.io/api/v6/:projectId/api/v7/auth/set-password"
payload = { "newPassword": "<string>" }
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({newPassword: '<string>'})
};
fetch('https://api.sublay.io/api/v6/:projectId/api/v7/auth/set-password', 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.sublay.io/api/v6/:projectId/api/v7/auth/set-password",
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([
'newPassword' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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.sublay.io/api/v6/:projectId/api/v7/auth/set-password"
payload := strings.NewReader("{\n \"newPassword\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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.sublay.io/api/v6/:projectId/api/v7/auth/set-password")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"newPassword\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sublay.io/api/v6/:projectId/api/v7/auth/set-password")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"newPassword\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "<string>"
}Auth Endpoints
Set Password
Set an initial password for an OAuth-only user
Set Password
curl --request POST \
--url https://api.sublay.io/api/v6/:projectId/api/v7/auth/set-password \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"newPassword": "<string>"
}
'import requests
url = "https://api.sublay.io/api/v6/:projectId/api/v7/auth/set-password"
payload = { "newPassword": "<string>" }
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({newPassword: '<string>'})
};
fetch('https://api.sublay.io/api/v6/:projectId/api/v7/auth/set-password', 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.sublay.io/api/v6/:projectId/api/v7/auth/set-password",
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([
'newPassword' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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.sublay.io/api/v6/:projectId/api/v7/auth/set-password"
payload := strings.NewReader("{\n \"newPassword\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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.sublay.io/api/v6/:projectId/api/v7/auth/set-password")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"newPassword\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sublay.io/api/v6/:projectId/api/v7/auth/set-password")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"newPassword\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "<string>"
}Sets an initial password for the currently authenticated user. This is for accounts that signed up through OAuth (or an external identity) and have no password yet — for example, so they can later sign in with email and password, or unlink their last OAuth identity without being locked out. Requires a valid access token in the
Returned when the user already has a password. Use
Change Password instead.
Authorization header.
This endpoint is only for users who do not already have a password. If the
user already has one, use Change Password
instead, which verifies the current password before changing it.
Headers
string
required
Bearer {accessToken} — a valid access token for the authenticated user.Body Parameters
string
required
The password to set for the account.
Response
boolean
true on success.string
Confirmation message:
"Password set successfully."Error Responses
User Not Found — 403
User Not Found — 403
{
"error": "User not found.",
"code": "auth/no-user-found"
}
Already Password Authenticated — 400
Already Password Authenticated — 400
{
"error": "User already has a password. Use change-password instead.",
"code": "auth/already-password-authenticated"
}
See Also
useAuthhook —setPassword- Change Password
- Unlink OAuth Identity
- Built-in Auth guide

