Skip to main content
GitHub
6 min read

API Reference

User

API endpoints for User

Content-Typeapplication/json
Version1.0.0
POST/user

Create user

Creates a new user account.

Request Body

application/json
idoptionalinteger
User ID
usernameoptionalstring
Login username
firstNameoptionalstring
First name
lastNameoptionalstring
Last name
emailoptionalstring
Email address
passwordoptionalstring
Account password
phoneoptionalstring
Phone number
userStatusoptionalinteger
User 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}'
POSThttps://petstore.swagger.io/v2/user
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
}'

Authenticates a user and returns a session token.

Parameters

usernamerequiredstring
The user name for login
passwordrequiredstring
The 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'
GEThttps://petstore.swagger.io/v2/user/login
curl -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'
GEThttps://petstore.swagger.io/v2/user/logout
curl -X GET 'https://petstore.swagger.io/v2/user/logout'

Returns user details by username.

Parameters

usernamerequiredstring
The 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}'
GEThttps://petstore.swagger.io/v2/user/{username}
curl -X GET 'https://petstore.swagger.io/v2/user/{username}'

Updates an existing user by username.

Parameters

usernamerequiredstring
Name of user to update

Request Body

application/json
idoptionalinteger
User ID
usernameoptionalstring
Login username
firstNameoptionalstring
First name
lastNameoptionalstring
Last name
emailoptionalstring
Email address
passwordoptionalstring
Account password
phoneoptionalstring
Phone number
userStatusoptionalinteger
User 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}'
PUThttps://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

usernamerequiredstring
The 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}'
DELETEhttps://petstore.swagger.io/v2/user/{username}
curl -X DELETE 'https://petstore.swagger.io/v2/user/{username}'