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

Modify user

PreviousGet userNextList users

Last updated 1 year ago

Redoc document (api spec)

This API endpoint allows updating a user's information by either their ID or email. The endpoint is "/api/user/{id_or_email}" where {id_or_email} is either the user's ID or email. This endpoint requires an API key with the "admin" permission for security.

The request must be in JSON format and contain the following parameters:

  • user_role: a string representing the user's role (example: "admin")

  • user_company: a string representing the user's company (example: "63c04c071ad80d5322929cb1")

  • user_company_txn: a string representing the user's company transaction (example: "63c04c071ad80d5322929cb1")

The response is also in JSON format and contains two properties:

  • error: an object containing error code and message (example: code: "040", message: "User not found")

  • data: an object containing the updated user information including:

    • _id: a string representing the user's ID (example: "MMGqKihnmmqyTgAy")

    • email: a string representing the user's email (example: "test@gmail.com")

    • password: a string representing the user's password

    • wallet: a string representing the user's wallet

    • user_role: a string representing the user's role

    • user_company: a string representing the user's company

    • user_company_txn: a string representing the user's company transaction

api-docs

Update user by ID or email

put
Authorizations
Path parameters
id_or_emailstringRequired

ID or email of the user to update

Body
user_rolestringOptionalExample: admin
user_companystringOptionalExample: 63c04c071ad80d5322929cb1
user_company_txnstringOptionalExample: 63c04c071ad80d5322929cb1
Responses
200
Successful response
application/json
put
PUT /api/user/{id_or_email} HTTP/1.1
Host: url to be defined
Authorization: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 109

{
  "user_role": "admin",
  "user_company": "63c04c071ad80d5322929cb1",
  "user_company_txn": "63c04c071ad80d5322929cb1"
}
200

Successful response

{
  "error": {
    "code": "040",
    "message": "User not found"
  },
  "data": {
    "user": {
      "_id": "MMGqKihnmmqyTgAy",
      "email": "marc.vergara.f@gmail.com",
      "password": "$2b$10$tj0TYFFNVsp1GnZo8DRO9O4nz5iGm3fVyth9FES3Is5/VbbJLEFa6",
      "wallet": "CBVE3R2ZV2UWTEXROOVT5GKWOQ5HULDPMEUJWCSA5JEWVTISCNHU3KJHWU",
      "user_role": "text",
      "user_company": "63c04c071ad80d5322929cb1",
      "user_company_txn": "63c04c071ad80d5322929cb1"
    }
  }
}