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