Skip to content

Commit

Permalink
Merge pull request #12 from turingschool/readme---login-endpoint-details
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
jdmchugh111 authored Aug 23, 2024
2 parents 73ca66e + be612ec commit a48d4f2
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
```

0 comments on commit a48d4f2

Please sign in to comment.