Skip to main content

User API Functions

This section describes operations related to users.

Creating a user

Creates a new user account.

Endpoint: https://petstore3.swagger.io/api/v3/user

Operation: POST

Examples

POST "https://petstore3.swagger.io/api/v3/user" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "api_key: <YOUR_API_KEY>" \
-d '{
"id": 0,
"username": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}'

Responses

| Code | Description | | default | successful operation |

Response example

200: successful operation

{
"id": 10,
"username": "theUser",
"firstName": "John",
"lastName": "James",
"email": "john@email.com",
"password": "12345",
"phone": "12345",
"userStatus": 1
}

Parameters

Request body
NameTypeDescription
bodyUser object(Required) The User object to create.

Creating a list of users with list

Creates list of users with given input list.

Endpoint: https://petstore3.swagger.io/api/v3/user/createWithList

Operation: POST

Examples

Examples

POST "https://petstore3.swagger.io/api/v3/user/createWithList" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "api_key: <YOUR_API_KEY>" \
-d \
[
{
"id": 0,
"username": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}
]

Responses

CodeDescription
defaultsuccessful operation
Response example

200: Successful operation

{
"id": 0,
"username": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}

Parameters

Request body
NameTypeDescription
bodyArray of User objects(Required) The list of User objects to create.

Logging in

Logs user into the system.

Endpoint: https://petstore3.swagger.io/api/v3/user/login

Operation: GET

Examples

GET "https://petstore3.swagger.io/api/v3/user/login?username=string&password=string" \
-H "accept: application/json" \
-H "api_key: <YOUR_API_KEY>"

Responses

CodeDescription
200successful operation
400Invalid username/password supplied
defaultUnexpected error

Response example

200: successful operation

{
"message": "logged in user session:abcdef12345"
}

Headers:

NameDescriptionType
X-Rate-LimitCalls per hour allowed by the user.integer
X-Expires-AfterDate in UTC when token expires.string

Parameters

Query parameters
NameTypeDescription
usernamestringThe username for login.
passwordstringThe password for login in clear text.

Logging out

Logs out current logged in user session.

Endpoint: https://petstore3.swagger.io/api/v3/user/logout

Operation: GET

Examples

GET "https://petstore3.swagger.io/api/v3/user/logout" \
-H "accept: application/json" \
-H "api_key: <YOUR_API_KEY>"

Responses

CodeDescription
200successful operation
defaultsuccessful operation
Response example

200: successful operation

{
"message": "Successfully logged out"
}

Parameters

None

Getting user by username

Gets a user by their username.

Endpoint: https://petstore3.swagger.io/api/v3/user/{username}

Operation: GET

Examples

GET "https://petstore3.swagger.io/api/v3/user/user1" \
-H "accept: application/json" \
-H "api_key: <YOUR_API_KEY>"

Responses

CodeDescription
200successful operation
400Invalid username supplied
404User not found
defaultUnexpected error

200: successful operation

{
"id": 0,
"username": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}

Parameters

Path parameters
NameTypeDescription
usernamestringThe username of the user to fetch. Use "user" for testing.

Updating a user

Updates a user.

Endpoint: https://petstore3.swagger.io/api/v3/user/{username}

Operation: PUT

Examples

PUT "https://petstore3.swagger.io/api/v3/user/user1" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "api_key: <YOUR_API_KEY>" \
-d '{
"id": 0,
"username": "user1",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}'

Responses

CodeDescription
200Successful operation
400Invalid user supplied
404User not found
defaultUnexpected error

(A successful update returns a 200 code with no response body.)

Parameters

Path parameters
NameTypeDescription
usernamestringThe username of the user to update
Request body
NameTypeDescription
bodyUser object(Required) The User object with updated information.

Deleting a user

Deletes a user.

Endpoint: https://petstore3.swagger.io/api/v3/user/{username}

Operation: DELETE

Examples

DELETE "https://petstore3.swagger.io/api/v3/user/user1" \
-H "accept: application/json" \
-H "api_key: <YOUR_API_KEY>"

Responses

CodeDescription
200User deleted
400Invalid username supplied
404User not found

(A successful deletion returns a 200 code with no response body.)

Parameters

Path parameters
NameTypeDescription
usernamestringThe username of the user to delete