From be612ec274148c6f12a112b8f10a22cad7f84d01 Mon Sep 17 00:00:00 2001 From: Noah Durbin <13364668+noahdurbin@users.noreply.github.com> Date: Fri, 23 Aug 2024 09:51:03 -0600 Subject: [PATCH] Update README.md --- README.md | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/README.md b/README.md index 5d492e7..c2a41c2 100644 --- a/README.md +++ b/README.md @@ -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": "user@example.com", + "password": "password123", + "password_confirmation": "password123" + } + ``` + - Successful Response (201 Created): + ```json + { + "data": { + "id": "1", + "type": "user", + "attributes": { + "email": "user@example.com" + } + } + } + ``` + - 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": "user@example.com", + "password": "password123" + } + ``` + - Successful Response (200 OK): + ```json + { + "data": { + "id": "1", + "type": "user", + "attributes": { + "email": "user@example.com" + } + } + } + ``` + - Error Response (401 Unauthorized): + ```json + { + "errors": [ + { + "message": "Invalid email or password" + } + ] + } + ```