This document outlines the available endpoints based on the provided controllers (LoginController and RegisterController).
Base URL Placeholder: http://localhost:8000
Authenticates a user and returns a JWT token.
POST /login
Content-Type: application/json
{
"email": "john.doe@example.com",
"password": "securepassword123"
}
curl --location 'http://localhost:8000/login' \
--header 'Content-Type: application/json' \
--data '{
"email": "john.doe@example.com",
"password": "securepassword123"
}'
{
"status": "ok",
"msg": "[100] Request ok.",
"code": "S_OK",
"data": {
"token": "<jwt>",
"user_id": 1,
"company_id": 1
}
}
{
"status": "fail",
"message": "Invalid credentials",
"code": "E_VALIDATE"
}
Creates a new user account in the database.
POST /register
Content-Type: application/json
{
"username": "John Doe",
"email": "john.doe@example.com",
"password": "securepassword123",
"phone": "+15550199",
"address": "123 Tech Street",
"city": "Silicon Valley",
"state": "CA",
"zip": "94000",
"country": "USA",
"kyc": 1,
"birthdate": 631152000,
"cpf": "12345678900",
"company_id": 1,
"role_id": 2
}
curl --location 'http://localhost:8000/register' \
--header 'Content-Type: application/json' \
--data '{
"username": "John Doe",
"email": "john.doe@example.com",
"password": "securepassword123",
"phone": "+15550199",
"address": "123 Tech Street",
"city": "Silicon Valley",
"state": "CA",
"zip": "94000",
"country": "USA",
"kyc": 1,
"birthdate": 631152000,
"cpf": "12345678900",
"company_id": 1,
"role_id": 1
}'
{
"status": "success",
"code": "S_CREATED",
"data": {
"user_id": 45,
"user_name": "John Doe",
"user_email": "john.doe@example.com",
"company_id": 1,
"role_id": 2
}
}
Email already exists
{
"status": "fail",
"message": "Missing field: phone",
"code": "E_VALIDATE"
}
Creates a company, a user linked to it, and a wallet (address/publicKey/privateKey) in a single transaction. Public endpoint (no auth).
POST /company/user/create
Content-Type: application/json
{
"company_name": "Acme Corp",
"username": "John Doe",
"email": "john.doe@example.com",
"password": "secret123",
"phone": "+55 11 99999-9999",
"address": "Rua A, 123",
"city": "Sao Paulo",
"state": "SP",
"zip": "01234-567",
"country": "BR",
"kyc": 1,
"birthdate": 631152000,
"cpf": "123.456.789-00",
"cnpj": "00000000000001"
}
curl --location 'http://localhost:8000/company/user/create' \
-H 'Content-Type: application/json' \
--data '{
"company_name": "MixTech",
"username": "LuvasLuvas",
"email": "Luvas@email.com",
"password": "secret123",
"phone": "+55 16 93939-2222",
"address": "Rua A, 123",
"city": "Sao Paulo",
"state": "SP",
"zip": "01234-567",
"country": "BR",
"kyc": 1,
"birthdate": 631152000,
"cpf": "12345678900",
"cnpj": "00000000000030"
}'
{
"status": "ok",
"msg": "[100] Request ok.",
"code": "S_CREATED",
"data": {
"company_id": 1,
"role_id": 1,
"user": {
"user_id": 1,
"user_name": "John Doe",
"user_email": "john.doe@example.com",
"company_id": 1,
"role_id": 1
},
"wallet_id": 1,
"wallet_address": "0x8AC9615b1a555BeA2938778aAef1ead35205c167"
}
}
{
"status": "failed",
"msg": "Password must be at least 8 characters",
"code": "E_VALIDATE",
"data": []
}
{
"status": "failed",
"msg": "Wallet generation failed",
"code": "E_INTERNAL",
"data": []
}
Updates the authenticated user's email. Requires JWT.
POST /user/change-email
Content-Type: application/json
Authorization: Bearer <JWT>
{
"email": "new.email@example.com"
}
curl --location 'http://localhost:8000/user/change-email' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <JWT>' \
--data '{"email":"new.email@example.com"}'
{
"status": "ok",
"msg": "[100] Request ok.",
"code": "S_UPDATED",
"data": {
"user_id": 1,
"user_email": "new.email@example.com"
}
}
{
"status": "failed",
"msg": "Email already in use or update failed",
"code": "E_VALIDATE",
"data": []
}
{
"status": "failed",
"msg": "Unauthorized",
"code": "E_VALIDATE",
"data": []
}
Changes the authenticated user's password. Requires JWT.
POST /user/change-password
Content-Type: application/json
Authorization: Bearer <JWT>
{
"current_password": "minhaSenhaAtual",
"new_password": "novaSenhaForte123"
}
curl --location 'http://localhost:8000/user/change-password' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <JWT>' \
--data '{"current_password":"minhaSenhaAtual","new_password":"novaSenhaForte123"}'
{
"status": "ok",
"msg": "[100] Request ok.",
"code": "S_UPDATED",
"data": {
"user_id": 1
}
}
{
"status": "failed",
"msg": "Invalid current password or update failed",
"code": "E_VALIDATE",
"data": []
}
{
"status": "failed",
"msg": "Unauthorized",
"code": "E_VALIDATE",
"data": []
}
Returns all commodities. No request body required. Requires JWT.
POST /commodities/get
Authorization: Bearer <JWT>
curl --location -X POST 'http://localhost:8000/commodities/get' \
-H 'Authorization: Bearer <JWT>'
{
"status": "ok",
"msg": "[100] Request ok.",
"code": "S_OK",
"data": [
{
"commodities_id": 1,
"name": "Gold",
"flag": "a"
}
]
}
{
"status": "fail",
"msg": "Commodities Not Found",
"code": "E_DATABASE",
"data": []
}
Creates a new commodity.
POST /commodity/create
Content-Type: application/json
{
"name": "Gold",
"flag": "a"
}
curl --location 'http://localhost:8000/commodity/create' \
-H 'Content-Type: application/json' \
--data '{
"name": "Gold",
"flag": "a"
}'
{
"status": "ok",
"msg": "[100] Request ok.",
"code": "S_CREATED",
"data": {
"commodities_id": 10,
"name": "Gold",
"flag": "a"
}
}
{
"status": "fail",
"msg": "Validation failed: name is required",
"code": "E_VALIDATE",
"data": []
}
Updates an existing commodity.
POST /commodity/update
Content-Type: application/json
{
"commodities_id": 10,
"name": "Silver",
"flag": "b"
}
You may send only name, only flag, or both.
curl --location 'http://localhost:8000/commodity/update' \
-H 'Content-Type: application/json' \
--data '{
"commodities_id": 10,
"name": "Silver",
"flag": "b"
}'
{
"status": "ok",
"msg": "[100] Request ok.",
"code": "S_UPDATED",
"data": {
"commodities_id": 10,
"name": "Silver",
"flag": "b"
}
}
No fields to update
{
"status": "fail",
"msg": "Validation failed: nothing to update",
"code": "E_VALIDATE",
"data": []
}
{
"status": "fail",
"msg": "Commodity Not Found or Not Updated",
"code": "E_DATABASE",
"data": []
}
Deletes a commodity by ID.
POST /commodity/delete
Content-Type: application/json
{
"commodities_id": 10
}
curl --location 'http://localhost:8000/commodity/delete' \
-H 'Content-Type: application/json' \
--data '{"commodities_id":10}'
{
"status": "ok",
"msg": "[100] Request ok.",
"code": "S_DELETED",
"data": {
"deleted": true
}
}
{
"status": "fail",
"msg": "Validation failed: invalid commodities_id",
"code": "E_VALIDATE",
"data": []
}
{
"status": "fail",
"msg": "Commodity Not Found",
"code": "E_DATABASE",
"data": []
}
Returns all tokens filtered by token_uf and commodities_name. Requires JWT.
POST /token/get
Content-Type: application/json
Authorization: Bearer <JWT>
{
"token_uf": "SP",
"commodities_name": "soja"
}
curl --location 'http://localhost:8000/token/get' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <JWT>' \
--data '{
"token_uf": "SP",
"commodities_name": "soja"
}'
{
"status": "ok",
"msg": "[100] Request ok.",
"code": "S_OK",
"data": [
{
"token_id": 1,
"token_external_id": "abc123",
"token_commodities_amount": 1000,
"token_commodities_value": 5000,
"token_uf": "SP",
"token_city": "Sao Paulo",
"token_content": "financial instrument",
"token_flag": "a",
"wallet_id": 1,
"chain_id": 1,
"commodities_id": 1,
"cpr_id": 1,
"user_id": 1
}
]
}
{
"status": "fail",
"msg": "Token Not Found",
"code": "E_DATABASE",
"data": []
}