Green earth docs
  • Green earth docs
  • Environment
  • Start
  • Api flow FAQ
  • Api endpoints
    • Login
    • Register
    • Automatic gebt distribution
    • Get transaction
    • List transactions
    • Get user
    • Modify user
    • List users
    • Create company (admin)
    • List company
    • Get company
  • Api errors
Powered by GitBook
On this page
  1. Api endpoints

Login

PreviousApi endpointsNextRegister

Last updated 1 year ago

Redoc document (api spec)

To use this endpoint, you will need to send an HTTP POST request to the URL /login. The request body should be in JSON format and should contain the following fields:

  • password: a string representing the user's password

Here's an example of what the request body might look like:

{
  "email": "user@example.com",
  "password": "password123"
}

If the login is successful, the API will return a response with a status code of 200 and a JSON body containing a success message and a JSON Web Token (JWT) that can be used to authenticate the user for future requests. The JSON body will look something like this:

{
  "data": {
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
  }
}

email: a string representing the user's email address, in the format ""

user@example.com
api-docs

Login an existing user

post
Body
emailstring ยท emailRequired

Email address for the user

Example: user@example.com
passwordstringRequired

Password for the user

Example: password123
Responses
200
OK
application/json
400
Bad Request
application/json
post
POST /api/login HTTP/1.1
Host: url to be defined
Content-Type: application/json
Accept: */*
Content-Length: 53

{
  "email": "user@example.com",
  "password": "password123"
}
{
  "error": {
    "code": "040",
    "message": "Wrong email or password"
  },
  "data": {
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
  }
}