Update User
curl --request PUT \
--url https://api.moonkey.fun/v1/auth/users/{user_id}/update \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"first_name": "John",
"middle_name": "",
"last_name": "Smith",
"emails": [
{
"email": "sandbox@moonkey.fun"
}
],
"phone_numbers": [
{
"phone_number": "+14152222222"
}
]
}
'import requests
url = "https://api.moonkey.fun/v1/auth/users/{user_id}/update"
payload = {
"first_name": "John",
"middle_name": "",
"last_name": "Smith",
"emails": [{ "email": "sandbox@moonkey.fun" }],
"phone_numbers": [{ "phone_number": "+14152222222" }]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
first_name: 'John',
middle_name: '',
last_name: 'Smith',
emails: [{email: 'sandbox@moonkey.fun'}],
phone_numbers: [{phone_number: '+14152222222'}]
})
};
fetch('https://api.moonkey.fun/v1/auth/users/{user_id}/update', 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.moonkey.fun/v1/auth/users/{user_id}/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'first_name' => 'John',
'middle_name' => '',
'last_name' => 'Smith',
'emails' => [
[
'email' => 'sandbox@moonkey.fun'
]
],
'phone_numbers' => [
[
'phone_number' => '+14152222222'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.moonkey.fun/v1/auth/users/{user_id}/update"
payload := strings.NewReader("{\n \"first_name\": \"John\",\n \"middle_name\": \"\",\n \"last_name\": \"Smith\",\n \"emails\": [\n {\n \"email\": \"sandbox@moonkey.fun\"\n }\n ],\n \"phone_numbers\": [\n {\n \"phone_number\": \"+14152222222\"\n }\n ]\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.put("https://api.moonkey.fun/v1/auth/users/{user_id}/update")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"first_name\": \"John\",\n \"middle_name\": \"\",\n \"last_name\": \"Smith\",\n \"emails\": [\n {\n \"email\": \"sandbox@moonkey.fun\"\n }\n ],\n \"phone_numbers\": [\n {\n \"phone_number\": \"+14152222222\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonkey.fun/v1/auth/users/{user_id}/update")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"first_name\": \"John\",\n \"middle_name\": \"\",\n \"last_name\": \"Smith\",\n \"emails\": [\n {\n \"email\": \"sandbox@moonkey.fun\"\n }\n ],\n \"phone_numbers\": [\n {\n \"phone_number\": \"+14152222222\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"user_id": "user_24wFP9pDa9YiMJLun94iKykoZs2",
"phone_numbers": [
{
"id": "pn_24oXBLRv6BoHXbNZoTAZkAFlRsy",
"verified": false,
"phone_number": "+14152222222",
"updated_at": 1642703333,
"created_at": 1642703333
}
],
"emails": [
{
"id": "email_24oXBL3PufzHkH1Jzyjc2EXYeo7",
"verified": false,
"email": "sandbox@moonkey.fun",
"updated_at": 1642703333,
"created_at": 1642703333
}
],
"user": {
"user_id": "user_24wFP9pDa9YiMJLun94iKykoZs2",
"first_name": "",
"middle_name": "",
"last_name": "",
"status": "active",
"active": true,
"updated_at": 1646873318,
"created_at": 1646873318,
"emails": [
{
"id": "email_26AjWpEcss2YyqFh1san6Wjjs7o",
"verified": true,
"email": "hello@moonkey.fun",
"updated_at": 1646957196,
"created_at": 1646873318
},
{
"id": "email_24oXBL3PufzHkH1Jzyjc2EXYeo7",
"verified": false,
"email": "sandbox@moonkey.fun",
"updated_at": 1642703333,
"created_at": 1642703333
}
],
"phone_numbers": [
{
"id": "pn_24oXBLRv6BoHXbNZoTAZkAFlRsy",
"verified": false,
"phone_number": "+14152222222",
"updated_at": 1642703333,
"created_at": 1642703333
}
],
"idp_providers": [
{
"id": "idpuser_28SRho5nbD045LGq2btZWXhkdjN",
"provider": "google",
"provider_subject": "100157402424066154830",
"idp_type": "oauth",
"method_id": "email_26AjWpEcss2YyqFh1san6Wjjs7o",
"method_type": "email",
"updated_at": 1651208121,
"created_at": 1651208121
}
],
"wallets": [
{
"id": "wallet_26AjWu075gRWMnjfPglcdoD2PAQ",
"public_address": "0x863c381a56a58370f435b0100faba94e6462b6d1",
"wallet_type": "ethereum",
"verified": true,
"is_default": true,
"is_read_only": false,
"is_imported": false,
"updated_at": 1646873319,
"created_at": 1646873319
}
],
"totps": [],
"webauthn_credentials": []
}
}Users
Update User
Update a user by ID.
Returns
A successful response returns a User object in user owith linked emails and phone numbers in emails and phone_numbers properties.
PUT
/
v1
/
auth
/
users
/
{user_id}
/
update
Update User
curl --request PUT \
--url https://api.moonkey.fun/v1/auth/users/{user_id}/update \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"first_name": "John",
"middle_name": "",
"last_name": "Smith",
"emails": [
{
"email": "sandbox@moonkey.fun"
}
],
"phone_numbers": [
{
"phone_number": "+14152222222"
}
]
}
'import requests
url = "https://api.moonkey.fun/v1/auth/users/{user_id}/update"
payload = {
"first_name": "John",
"middle_name": "",
"last_name": "Smith",
"emails": [{ "email": "sandbox@moonkey.fun" }],
"phone_numbers": [{ "phone_number": "+14152222222" }]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
first_name: 'John',
middle_name: '',
last_name: 'Smith',
emails: [{email: 'sandbox@moonkey.fun'}],
phone_numbers: [{phone_number: '+14152222222'}]
})
};
fetch('https://api.moonkey.fun/v1/auth/users/{user_id}/update', 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.moonkey.fun/v1/auth/users/{user_id}/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'first_name' => 'John',
'middle_name' => '',
'last_name' => 'Smith',
'emails' => [
[
'email' => 'sandbox@moonkey.fun'
]
],
'phone_numbers' => [
[
'phone_number' => '+14152222222'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.moonkey.fun/v1/auth/users/{user_id}/update"
payload := strings.NewReader("{\n \"first_name\": \"John\",\n \"middle_name\": \"\",\n \"last_name\": \"Smith\",\n \"emails\": [\n {\n \"email\": \"sandbox@moonkey.fun\"\n }\n ],\n \"phone_numbers\": [\n {\n \"phone_number\": \"+14152222222\"\n }\n ]\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.put("https://api.moonkey.fun/v1/auth/users/{user_id}/update")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"first_name\": \"John\",\n \"middle_name\": \"\",\n \"last_name\": \"Smith\",\n \"emails\": [\n {\n \"email\": \"sandbox@moonkey.fun\"\n }\n ],\n \"phone_numbers\": [\n {\n \"phone_number\": \"+14152222222\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonkey.fun/v1/auth/users/{user_id}/update")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"first_name\": \"John\",\n \"middle_name\": \"\",\n \"last_name\": \"Smith\",\n \"emails\": [\n {\n \"email\": \"sandbox@moonkey.fun\"\n }\n ],\n \"phone_numbers\": [\n {\n \"phone_number\": \"+14152222222\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"user_id": "user_24wFP9pDa9YiMJLun94iKykoZs2",
"phone_numbers": [
{
"id": "pn_24oXBLRv6BoHXbNZoTAZkAFlRsy",
"verified": false,
"phone_number": "+14152222222",
"updated_at": 1642703333,
"created_at": 1642703333
}
],
"emails": [
{
"id": "email_24oXBL3PufzHkH1Jzyjc2EXYeo7",
"verified": false,
"email": "sandbox@moonkey.fun",
"updated_at": 1642703333,
"created_at": 1642703333
}
],
"user": {
"user_id": "user_24wFP9pDa9YiMJLun94iKykoZs2",
"first_name": "",
"middle_name": "",
"last_name": "",
"status": "active",
"active": true,
"updated_at": 1646873318,
"created_at": 1646873318,
"emails": [
{
"id": "email_26AjWpEcss2YyqFh1san6Wjjs7o",
"verified": true,
"email": "hello@moonkey.fun",
"updated_at": 1646957196,
"created_at": 1646873318
},
{
"id": "email_24oXBL3PufzHkH1Jzyjc2EXYeo7",
"verified": false,
"email": "sandbox@moonkey.fun",
"updated_at": 1642703333,
"created_at": 1642703333
}
],
"phone_numbers": [
{
"id": "pn_24oXBLRv6BoHXbNZoTAZkAFlRsy",
"verified": false,
"phone_number": "+14152222222",
"updated_at": 1642703333,
"created_at": 1642703333
}
],
"idp_providers": [
{
"id": "idpuser_28SRho5nbD045LGq2btZWXhkdjN",
"provider": "google",
"provider_subject": "100157402424066154830",
"idp_type": "oauth",
"method_id": "email_26AjWpEcss2YyqFh1san6Wjjs7o",
"method_type": "email",
"updated_at": 1651208121,
"created_at": 1651208121
}
],
"wallets": [
{
"id": "wallet_26AjWu075gRWMnjfPglcdoD2PAQ",
"public_address": "0x863c381a56a58370f435b0100faba94e6462b6d1",
"wallet_type": "ethereum",
"verified": true,
"is_default": true,
"is_read_only": false,
"is_imported": false,
"updated_at": 1646873319,
"created_at": 1646873319
}
],
"totps": [],
"webauthn_credentials": []
}
}Authorizations
Auth Platform API includes all the Auth related features. All Users, Phone Numbers, Emails, and OTPs are associated with an App as the container.
Endpoints only accept App's Secret API keys other than certain endpoints that are used client side or via SDK that accept the public_token.
Authentication using App Api Key
Header:
Authorization: Bearer {api_key}
Authenticated Request
curl \
-X GET https://api.moonkey.fun/v1/auth/users/user_24wFP9pDa9YiMJLun94iKykoZs2 \
-H "Authorization: Bearer sk_test_pRqweh3wvWmJAAVYv7Z0T5iPLzFM4ql0muoyQcjOxGeN3p1r"
Body
application/json
A flexible JSON object for storing custom data about a user. You can store any arbitrary data as key-value pairs.
Update Behavior:
- By default, metadata updates are merged at the top level only
- Send
nullvalues for specific fields to delete those fields (merge mode only) - Send
{}(empty object) to clear all metadata - Send
nullfor the metadata field itself will be ignored (as if metadata was not sent) - Deeply nested objects and arrays are NOT merged - they replace the entire top-level key
- Set
replace_metadata: trueto replace all metadata without merging