Update a user
curl -X PATCH "https://mail.haltman.io/api/admin/users/123" \
-H "Content-Type: application/json" \
-H "X-CSRF-Token: YOUR_API_KEY" \
-d '{
"username": "John Doe",
"email": "user@example.com",
"password": "example_string",
"is_active": true,
"is_admin": true
}'
import requests
import json
url = "https://mail.haltman.io/api/admin/users/123"
headers = {
"Content-Type": "application/json",
"X-CSRF-Token": "YOUR_API_KEY"
}
data = {
"username": "John Doe",
"email": "user@example.com",
"password": "example_string",
"is_active": true,
"is_admin": true
}
response = requests.patch(url, headers=headers, json=data)
print(response.json())
const response = await fetch("https://mail.haltman.io/api/admin/users/123", {
method: "PATCH",
headers: {
"Content-Type": "application/json",
"X-CSRF-Token": "YOUR_API_KEY"
},
body: JSON.stringify({
"username": "John Doe",
"email": "user@example.com",
"password": "example_string",
"is_active": true,
"is_admin": true
})
});
const data = await response.json();
console.log(data);
package main
import (
"fmt"
"net/http"
"bytes"
"encoding/json"
)
func main() {
data := []byte(`{
"username": "John Doe",
"email": "user@example.com",
"password": "example_string",
"is_active": true,
"is_admin": true
}`)
req, err := http.NewRequest("PATCH", "https://mail.haltman.io/api/admin/users/123", bytes.NewBuffer(data))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-CSRF-Token", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}
require 'net/http'
require 'json'
uri = URI('https://mail.haltman.io/api/admin/users/123')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(uri)
request['Content-Type'] = 'application/json'
request['X-CSRF-Token'] = 'YOUR_API_KEY'
request.body = '{
"username": "John Doe",
"email": "user@example.com",
"password": "example_string",
"is_active": true,
"is_admin": true
}'
response = http.request(request)
puts response.body
{
"ok": true,
"created": true,
"updated": true,
"deleted": true,
"item": {
"id": 123,
"username": "John Doe",
"email": "user@example.com",
"email_verified_at": "2024-12-25T10:00:00Z",
"is_active": 42,
"is_admin": true,
"created_at": "2024-12-25T10:00:00Z",
"updated_at": "2024-12-25T10:00:00Z",
"last_login_at": "2024-12-25T10:00:00Z"
}
}
{
"error": "example_string",
"field": "example_string",
"reason": "example_string",
"hint": "example_string",
"constraints": {}
}
{
"error": "example_string"
}
{
"error": "Unauthorized",
"message": "Authentication required. Please provide a valid API token",
"code": 401
}
{
"error": "Forbidden",
"message": "You don't have permission to access this resource",
"code": 403
}
{
"error": "Not Found",
"message": "The requested resource was not found",
"code": 404
}
{
"error": "Conflict",
"message": "The request conflicts with the current state of the resource",
"code": 409,
"details": "Resource already exists"
}
{
"error": "example_string",
"where": "example_string",
"reason": "example_string"
}
PATCH
/api/admin/users/{id}PATCH
API Key (cookie: __Host-access)
__Host-accessstring
RequiredAccess-session cookie used for user and admin authentication.
Access-session cookie used for user and admin authentication.
API Key (header: X-CSRF-Token)
X-CSRF-Tokenstring
RequiredCSRF token derived from the current session family.
CSRF token derived from the current session family.
path
idinteger
RequiredResource identifier.
Content-Typestring
RequiredThe media type of the request body
Options: application/json
usernamestring
Min length: 1 • Max length: 64
emailstring
Format: email
passwordstring
Min length: 8 • Max length: 128
Request Preview
Response
Response will appear here after sending the request
Authentication
path
parameterstring
RequiredAPI Key for authentication. Access-session cookie used for user and admin authentication.
header
X-CSRF-Tokenstring
RequiredAPI Key for authentication. CSRF token derived from the current session family.
Path Parameters
idinteger
RequiredResource identifier.
Responses
okboolean
Requiredcreatedboolean
updatedboolean
deletedboolean
itemobject
RequiredWas this page helpful?
Last updated 2 days ago
Built with Documentation.AI