Update User
curl --request PUT \
--url https://api.petstoreapi.com/v1/users/{id} \
--header 'Content-Type: application/json' \
--data '
{
"firstName": "Jeffrey",
"lastName": "Kris",
"email": "jeffrey.kris@example.com",
"phone": "+18634063542"
}
'import requests
url = "https://api.petstoreapi.com/v1/users/{id}"
payload = {
"firstName": "Jeffrey",
"lastName": "Kris",
"email": "jeffrey.kris@example.com",
"phone": "+18634063542"
}
headers = {"Content-Type": "application/json"}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
firstName: 'Jeffrey',
lastName: 'Kris',
email: 'jeffrey.kris@example.com',
phone: '+18634063542'
})
};
fetch('https://api.petstoreapi.com/v1/users/{id}', 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.petstoreapi.com/v1/users/{id}",
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([
'firstName' => 'Jeffrey',
'lastName' => 'Kris',
'email' => 'jeffrey.kris@example.com',
'phone' => '+18634063542'
]),
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.petstoreapi.com/v1/users/{id}"
payload := strings.NewReader("{\n \"firstName\": \"Jeffrey\",\n \"lastName\": \"Kris\",\n \"email\": \"jeffrey.kris@example.com\",\n \"phone\": \"+18634063542\"\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.petstoreapi.com/v1/users/{id}")
.header("Content-Type", "application/json")
.body("{\n \"firstName\": \"Jeffrey\",\n \"lastName\": \"Kris\",\n \"email\": \"jeffrey.kris@example.com\",\n \"phone\": \"+18634063542\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.petstoreapi.com/v1/users/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"firstName\": \"Jeffrey\",\n \"lastName\": \"Kris\",\n \"email\": \"jeffrey.kris@example.com\",\n \"phone\": \"+18634063542\"\n}"
response = http.request(request)
puts response.read_body{}{
"type": "https://petstoreapi.com/errors/bad-request",
"title": "Bad Request",
"status": 400,
"detail": "Invalid value for parameter 'status'. Must be one of: available, pending, sold.",
"instance": "/pets"
}{
"type": "https://petstoreapi.com/errors/not-found",
"title": "Not Found",
"status": 404,
"detail": "The requested pet with ID '123' was not found.",
"instance": "/pets/123"
}{
"type": "https://petstoreapi.com/errors/validation-error",
"title": "Validation Error",
"status": 422,
"detail": "The request body contains validation errors.",
"instance": "/pets",
"errors": [
{
"field": "name",
"message": "Pet name is required",
"code": "required_field"
},
{
"field": "status",
"message": "Invalid status value",
"code": "invalid_format"
}
]
}User
Update User
Update user information. Only the logged-in user can perform this operation.
PUT
/
users
/
{id}
Update User
curl --request PUT \
--url https://api.petstoreapi.com/v1/users/{id} \
--header 'Content-Type: application/json' \
--data '
{
"firstName": "Jeffrey",
"lastName": "Kris",
"email": "jeffrey.kris@example.com",
"phone": "+18634063542"
}
'import requests
url = "https://api.petstoreapi.com/v1/users/{id}"
payload = {
"firstName": "Jeffrey",
"lastName": "Kris",
"email": "jeffrey.kris@example.com",
"phone": "+18634063542"
}
headers = {"Content-Type": "application/json"}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
firstName: 'Jeffrey',
lastName: 'Kris',
email: 'jeffrey.kris@example.com',
phone: '+18634063542'
})
};
fetch('https://api.petstoreapi.com/v1/users/{id}', 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.petstoreapi.com/v1/users/{id}",
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([
'firstName' => 'Jeffrey',
'lastName' => 'Kris',
'email' => 'jeffrey.kris@example.com',
'phone' => '+18634063542'
]),
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.petstoreapi.com/v1/users/{id}"
payload := strings.NewReader("{\n \"firstName\": \"Jeffrey\",\n \"lastName\": \"Kris\",\n \"email\": \"jeffrey.kris@example.com\",\n \"phone\": \"+18634063542\"\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.petstoreapi.com/v1/users/{id}")
.header("Content-Type", "application/json")
.body("{\n \"firstName\": \"Jeffrey\",\n \"lastName\": \"Kris\",\n \"email\": \"jeffrey.kris@example.com\",\n \"phone\": \"+18634063542\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.petstoreapi.com/v1/users/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"firstName\": \"Jeffrey\",\n \"lastName\": \"Kris\",\n \"email\": \"jeffrey.kris@example.com\",\n \"phone\": \"+18634063542\"\n}"
response = http.request(request)
puts response.read_body{}{
"type": "https://petstoreapi.com/errors/bad-request",
"title": "Bad Request",
"status": 400,
"detail": "Invalid value for parameter 'status'. Must be one of: available, pending, sold.",
"instance": "/pets"
}{
"type": "https://petstoreapi.com/errors/not-found",
"title": "Not Found",
"status": 404,
"detail": "The requested pet with ID '123' was not found.",
"instance": "/pets/123"
}{
"type": "https://petstoreapi.com/errors/validation-error",
"title": "Validation Error",
"status": 422,
"detail": "The request body contains validation errors.",
"instance": "/pets",
"errors": [
{
"field": "name",
"message": "Pet name is required",
"code": "required_field"
},
{
"field": "status",
"message": "Invalid status value",
"code": "invalid_format"
}
]
}Headers
Optional tenant identifier for data isolation. When provided, all operations will be scoped to this tenant, ensuring data separation between different organizations or users. If omitted, operations will access the shared/public data pool where data may be visible to and modified by other users.
Path Parameters
Unique identifier for the user
Body
application/json
User account information
Unique username for login
Required string length:
3 - 50Examples:
"johndoe"
"mysqluser"
User email address
Examples:
"user@example.com"
"john.doe@petstore.com"
User's first name
Examples:
"John"
"Jane"
User's last name
Examples:
"Doe"
"Smith"
Phone number in E.164 format
Pattern:
^\+?[1-9]\d{1,14}$Example:
"+12025551234"
Show child attributes
Show child attributes
Response
User updated successfully.
The response is of type object.
⌘I