Skip to content

Organization Routes

This page provides routes for managing organizations. The following routes are available:

GET /organizations

Retrieves a list of all organizations.

Description: This endpoint retrieves a list of all organizations in the system.

Authentication: This route requires authentication with the ADMIN role and the read permission.

Parameters: None

Response:

  • Success Response (200 OK):
json
{
  "organization": [
    {
      "accessScope": ["write", "update", "delete", "read"],
      "acronym": "Ggl",
      "apiKeys": [],
      "deleted": false,
      "organizationName": "Google 1q1",
      "ownedBy": null,
      "id": "667d1c57a1313e4b42d0936f"
    },
    {
      "accessScope": ["write", "delete", "read"],
      "acronym": "100",
      "apiKeys": [],
      "deleted": false,
      "organizationName": "ORG100",
      "ownedBy": {
        "deleted": false,
        "email": "owner100@test.com",
        "orgId": "667d1142a1313e4b42d09228",
        "credits": [],
        "creditsRemaining": 0,
        "creditsTotal": 0,
        "creditsUsed": 0,
        "id": "667d115c4504a75cb07ac5aa"
      },
      "blockchainDetails": {
        "address": "<account public address>",
        "mnemonic": "<mnemonic phrase>",
        "privateKey": "<private key>"
      },
      "id": "667d1142a1313e4b42d09228"
    },
    {
      "accessScope": ["write", "update", "delete", "read"],
      "acronym": "MNG",
      "apiKeys": [],
      "deleted": false,
      "organizationName": "My New Org123",
      "ownedBy": {
        "deleted": false,
        "email": "john@own.com",
        "orgId": "667d0aeda1313e4b42d09135",
        "credits": [],
        "creditsRemaining": 0,
        "creditsTotal": 0,
        "creditsUsed": 0,
        "id": "667d0b32c2118d1055eae7ae"
      },
      "blockchainDetails": {
        "address": "<account public address>",
        "mnemonic": "<mnemonic phrase>",
        "privateKey": "<private key>"
      },
      "id": "667d0aeda1313e4b42d09135"
    }
  ]
}

Errors: None

Usage: To retrieve a list of all organizations, send a GET request to /organizations.

GET /organizations/:orgId

Retrieves details of a specific organization by ID.

Description: This endpoint retrieves the details of a specific organization based on the provided ID.

Authentication: This route requires authentication with the USER role and the read permission.

Parameters:

  • orgId (required): The ID of the organization to retrieve.

Response:

  • Success Response (200 OK):
json
{
  "organization": {
    "accessScope": ["write", "update", "delete", "read"],
    "acronym": "Ggl",
    "apiKeys": [],
    "deleted": false,
    "organizationName": "Google 1q1",
    "ownedBy": null,
    "blockchainDetails": {
      "address": "<account public address>",
      "mnemonic": "<mnemonic phrase>",
      "privateKey": "<private key>"
    },
    "id": "667d1c57a1313e4b42d0936f"
  },
  "accountBalance": "0.01"
}
  • Error Response (404 Not Found):

    json
    {
      "error": "Organization not found"
    }

Errors:

  • 404 Not Found: Returned when the organization with the specified ID is not found.

Usage: To retrieve the details of a specific organization, send a GET request to /organizations/:orgId, replacing :orgId with the ID of the organization you want to retrieve.

POST /organizations

Creates a new organization.

Description: This endpoint creates a new organization with the provided details. It also creates a blockchain account for the organization, and the account address is pushed into the blockchain.

Authentication: This route requires authentication with the ADMIN role and the create and write permission.

Request Body:

json
{
  "accessScope": ["read", "write"], //(array, required) scopes of the organization
  "acronym": "NEW212", //(string,required) acronym of the organization
  "organizationName": "New Org123" //(string,required) name of the organization
}

Response:

  • Success Response (201 Created):
json
{
  "organization": {
    "accessScope": [""],
    "acronym": "MN35H",
    "apiKeys": [],
    "blockchainDetails": {
      "address": "<account public address>",
      "mnemonic": "<mnemonic phrase>",
      "privateKey": "<private key>"
    },
    "deleted": false,
    "organizationName": "My Company 356 Hare Yes",
    "id": "66e291341323203718dcf014"
  }
}
  • Error Response (400 Bad Request):
json
{
  "error": "Invalid request body"
}

Errors:

  • 400 Bad Request: Returned when the request body is invalid or missing required fields.

Usage: To create a new organization, send a POST request to /organizations with a JSON request body containing the name and description of the new organization.

PATCH /organizations/:orgId

Updates an existing organization by ID.

Description: This endpoint updates the details of an existing organization with the provided ID.

Authentication: This route requires authentication with the ADMIN role and the write and update permission.

Parameters:

  • orgId (required): The ID of the organization to update.

Request Body:

json
{
  "accessScope": ["read", "write", "update"], //(array, optional) scopes of the organization
  "acronym": "NEW", //(string,optional) acronym of the organization
  "organizationName": "Updated Org" //(string,optional) name of the organization
}

Response:

  • Success Response (200 OK):
json
{
  "organization": {
    "accessScope": ["read", "write", "update"],
    "acronym": "NEW",
    "apiKeys": [],
    "deleted": false,
    "organizationName": "Updated Org",
    "id": "667d4ffa78a53bb62ef16ea5"
  }
}
  • Error Response (404 Not Found):
json
{
  "error": "Organization not found"
}
  • Error Response (400 Bad Request):
json
{
  "error": "Invalid request body"
}

Errors:

  • 404 Not Found: Returned when the organization with the specified ID is not found.
  • 400 Bad Request: Returned when the request body is invalid or missing required fields.

Usage: To update an existing organization, send a PATCH request to /organizations/:orgId, replacing :orgId with the ID of the organization you want to update. Include a JSON request body with the updated fields.

DELETE /organizations/:orgId

Deletes an organization by ID.

Description: This endpoint deletes an existing organization with the provided ID.

Authentication: This route requires authentication with the ADMIN role and the delete permission.

Parameters:

  • orgId (required): The ID of the organization to delete.

Response:

  • Success Response (204 No Content):
json
{
  "deletedOrganization": {
    "accessScope": ["read", "write", "update"],
    "acronym": "NEW",
    "apiKeys": [],
    "deleted": true,
    "organizationName": "Updated Org",
    "id": "667d4ffa78a53bb62ef16ea5"
  }
}
  • Error Response (404 Not Found):
json
{
  "error": "Organization not found"
}

Errors:

  • 404 Not Found: Returned when the organization with the specified ID is not found.

Usage: To delete an existing organization, send a DELETE request to /organizations/:orgId, replacing :orgId with the ID of the organization you want to delete.

API Documentation created with ❤️ by TrackGenesis