-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from turingschool/readme---login-endpoint-details
Update README.md
- Loading branch information
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,71 @@ This is the backend API repository for TurLink. TurLink is a link shortener app | |
- to use endpoints in development enivronment, run `rails s` and use `http://localhost:5000` as your base url | ||
|
||
## API Endpoints | ||
|
||
### User Registration | ||
- **POST** `/api/v1/users` | ||
- Description: Creates a new user account. | ||
- Request Body: | ||
```json | ||
{ | ||
"email": "[email protected]", | ||
"password": "password123", | ||
"password_confirmation": "password123" | ||
} | ||
``` | ||
- Successful Response (201 Created): | ||
```json | ||
{ | ||
"data": { | ||
"id": "1", | ||
"type": "user", | ||
"attributes": { | ||
"email": "[email protected]" | ||
} | ||
} | ||
} | ||
``` | ||
- Error Response (422 Unprocessable Entity): | ||
```json | ||
{ | ||
"errors": [ | ||
{ | ||
"status": "422", | ||
"message": "Email has already been taken" | ||
} | ||
] | ||
} | ||
``` | ||
|
||
### User Login | ||
- **POST** `/api/v1/sessions` | ||
- Description: Authenticates a user and creates a session. | ||
- Request Body: | ||
```json | ||
{ | ||
"email": "[email protected]", | ||
"password": "password123" | ||
} | ||
``` | ||
- Successful Response (200 OK): | ||
```json | ||
{ | ||
"data": { | ||
"id": "1", | ||
"type": "user", | ||
"attributes": { | ||
"email": "[email protected]" | ||
} | ||
} | ||
} | ||
``` | ||
- Error Response (401 Unauthorized): | ||
```json | ||
{ | ||
"errors": [ | ||
{ | ||
"message": "Invalid email or password" | ||
} | ||
] | ||
} | ||
``` |