API Reference
User
API endpoints for User
Creates a new user account.
Request Body
application/jsonidoptionalintegerUser ID
usernameoptionalstringLogin username
firstNameoptionalstringFirst name
lastNameoptionalstringLast name
emailoptionalstringEmail address
passwordoptionalstringAccount password
phoneoptionalstringPhone number
userStatusoptionalintegerUser status (0=active)
Responses
200User created
Request Example
curl -X POST 'https://petstore.swagger.io/v2/user' \
-H 'Content-Type: application/json' \
-d '{"id":10,"username":"string","firstName":"string","lastName":"string","email":"string","password":"string","phone":"string","userStatus":0}'POST
https://petstore.swagger.io/v2/usercurl -X POST 'https://petstore.swagger.io/v2/user' \
-H 'Content-Type: application/json' \
-d '{
"id": 10,
"username": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}'Authenticates a user and returns a session token.
Parameters
usernamerequiredstringThe user name for login
passwordrequiredstringThe password for login in clear text
Responses
200Successful operation (returns session token in X-Rate-Limit and X-Expires-After headers)
400Invalid username/password supplied
Request Example
curl -X GET 'https://petstore.swagger.io/v2/user/login'GET
https://petstore.swagger.io/v2/user/logincurl -X GET 'https://petstore.swagger.io/v2/user/login'Terminates the current user session.
Responses
200Successful operation
Request Example
curl -X GET 'https://petstore.swagger.io/v2/user/logout'GET
https://petstore.swagger.io/v2/user/logoutcurl -X GET 'https://petstore.swagger.io/v2/user/logout'Returns user details by username.
Parameters
usernamerequiredstringThe name of the user to fetch
Responses
200Successful operation
Example Response
{
"id": 10,
"username": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}400Invalid username supplied
404User not found
Request Example
curl -X GET 'https://petstore.swagger.io/v2/user/{username}'GET
https://petstore.swagger.io/v2/user/{username}curl -X GET 'https://petstore.swagger.io/v2/user/{username}'Updates an existing user by username.
Parameters
usernamerequiredstringName of user to update
Request Body
application/jsonidoptionalintegerUser ID
usernameoptionalstringLogin username
firstNameoptionalstringFirst name
lastNameoptionalstringLast name
emailoptionalstringEmail address
passwordoptionalstringAccount password
phoneoptionalstringPhone number
userStatusoptionalintegerUser status (0=active)
Responses
200User updated
400Invalid user supplied
404User not found
Request Example
curl -X PUT 'https://petstore.swagger.io/v2/user/{username}' \
-H 'Content-Type: application/json' \
-d '{"id":10,"username":"string","firstName":"string","lastName":"string","email":"string","password":"string","phone":"string","userStatus":0}'PUT
https://petstore.swagger.io/v2/user/{username}curl -X PUT 'https://petstore.swagger.io/v2/user/{username}' \
-H 'Content-Type: application/json' \
-d '{
"id": 10,
"username": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}'Deletes a user by username.
Parameters
usernamerequiredstringThe name of the user to delete
Responses
200User deleted
400Invalid username supplied
404User not found
Request Example
curl -X DELETE 'https://petstore.swagger.io/v2/user/{username}'DELETE
https://petstore.swagger.io/v2/user/{username}curl -X DELETE 'https://petstore.swagger.io/v2/user/{username}'