1. Auth
Personal Finance Tracker
  • Personal Finance Tracker
  • Auth
    • Register
      POST
    • Login
      POST
    • Email Verification
      POST
    • Forgot Password
      POST
    • Reset Password
      POST
    • Resend Verification Code
      POST
  • Finance
    • Wallet
      • Create Wallet
      • Get All Wallet
      • Get Detail Wallet
    • Transaction
      • Create New Transaction
      • Get Summary By WalletId
      • Delete Transaction
      • Update Transaction
      • Get Summary
    • Category
      • Create Category
      • Get All Category
    • Budget
      • Create Budget
      • Get All
      • Get Detail
  • User
    • Get My Profile
      GET
  • Schemas
    • Finance
      • Wallet
  1. Auth

Register

Developing
POST
/api/v1/auth/register

API Documentation: Register Endpoint#

Register a New User#

Description: This endpoint allows new users to register for an account. Upon successful registration, a verification email will be sent to the user's provided email address with a verification code.

Request#

Headers#

Content-Type: application/json

Body Parameters#

ParameterTypeRequiredDescription
emailstringYesThe email address of the user.
passwordstringYesThe password for the account.
namestringYesThe name of the user (optional).

Example Request#

POST /api/v1/auth/register
Content-Type: application/json

{
    "email": "user@example.com",
    "password": "yourSecurePassword",
    "name": "John Doe"
}

Response#

Success Response#

Status Code: 200 Success
Response Body:
{
    "status": "success",
    "message": "Email verification has been sent to your email"
}

Error Responses#

400 Bad Request
Response Body:
{
    "status": "error",
    "message": "Email and Password are required"
}
500 Internal Server Error
Response Body:
{
    "status": "error",
    "message": "An unexpected error occurred"
}

Workflow#

1.
Input Validation: The API checks if both email and password are provided in the request body. If either is missing, a 400 Bad Request error is returned.
2.
Token Generation: A unique verification token is generated for the user.
3.
User Creation: A new user record is created in the database with the provided email, hashed password, name, verification token, and a flag indicating the user is not yet verified.
4.
Email Verification: An email containing the verification token is sent to the user's provided email address. The email includes a link for the user to verify their account.
5.
Transaction Management: The operation is wrapped in a transaction to ensure that either all operations succeed or none do. In case of any errors, the transaction is rolled back.

Notes#

Ensure that your server is configured to send emails, and the PUBLIC_URL environment variable is set to the correct domain.
The token sent via email must be verified before the user can log in.

Request

Authorization
Provide your bearer token in the
Authorization
header when making requests to protected resources.
Example:
Authorization: Bearer ********************
Body Params application/json

Example
{
    "name" : "Liu Purnomo",
    "email": "hi@liupurnomo.com",
    "password": "Password321!"
}

Request Code Samples

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request POST '/api/v1/auth/register' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name" : "Liu Purnomo",
    "email": "hi@liupurnomo.com",
    "password": "Password321!"
}'

Responses

🟢200Success
application/json
Body

Example
{}
Modified at 2024-10-06 04:30:35
Previous
Personal Finance Tracker
Next
Login
Built with