{
  "openapi": "3.0.4",
  "info": {
    "title": "DER Connect Principal API",
    "description": "Provides endpoints to manage the platform.",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.traxes.io/connect"
    }
  ],
  "paths": {
    "/v1/collectives": {
      "post": {
        "tags": [
          "Collectives"
        ],
        "summary": "Creates a new collective",
        "description": "Creates a new collective and returns the created collective",
        "operationId": "CreateCollectiveEndpoint",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Connect.Service.Principal.App.Models.V1.CreateCollectiveRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connect.Service.Principal.App.Models.V1.Collective"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connect.Errors.Results.ConnectApiErrorResult"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Collectives"
        ],
        "summary": "List Collectives",
        "description": "Returns a list of Collectives accessible to the authenticated user",
        "operationId": "ListCollectivesEndpoint",
        "parameters": [
          {
            "name": "pageSize",
            "in": "query",
            "description": "The number of Collectives per page",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 25
            }
          },
          {
            "name": "continuationToken",
            "in": "query",
            "description": "The token used to retrieve the next page",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connect.Service.Principal.App.Models.V1.PagedCollectives"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connect.Errors.Results.ConnectApiErrorResult"
                }
              }
            }
          }
        }
      }
    },
    "/v1/collectives/{collectiveId}": {
      "delete": {
        "tags": [
          "Collectives"
        ],
        "summary": "Deletes a collective by its ID",
        "description": "Deletes a collective and all its associations. This action is irreversible",
        "operationId": "DeleteCollectiveEndpoint",
        "parameters": [
          {
            "name": "collectiveId",
            "in": "path",
            "description": "The ID of the collective to delete",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "5a554157-5a5a-4547-384c-423033333139"
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connect.Errors.Results.ConnectApiErrorResult"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Collectives"
        ],
        "summary": "Retrieve a Collective",
        "description": "Returns a specific Collective by id",
        "operationId": "GetCollectiveByIdEndpoint",
        "parameters": [
          {
            "name": "collectiveId",
            "in": "path",
            "description": "The id of the Collective",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "5a554157-5a5a-4547-384c-423033333139"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connect.Service.Principal.App.Models.V1.Collective"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connect.Errors.Results.ConnectApiErrorResult"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Collectives"
        ],
        "summary": "Update a Collective",
        "description": "Updates a Collective and returns the updated Collective",
        "operationId": "UpdateCollectiveEndpoint",
        "parameters": [
          {
            "name": "collectiveId",
            "in": "path",
            "description": "The id of the Collective",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "5a554157-5a5a-4547-384c-423033333139"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Connect.Service.Principal.App.Models.V1.CollectiveRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connect.Service.Principal.App.Models.V1.Collective"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connect.Errors.Results.ConnectApiErrorResult"
                }
              }
            }
          }
        }
      }
    },
    "/v1/collectives/{collectiveId}/properties": {
      "put": {
        "tags": [
          "Custom properties"
        ],
        "summary": "Update the custom properties of a Collective",
        "description": "Updates the custom properties of a Collective and returns the updated Collective",
        "operationId": "UpdateCollectiveCustomPropertiesEndpoint",
        "parameters": [
          {
            "name": "collectiveId",
            "in": "path",
            "description": "The id of the Collective",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "5a554157-5a5a-4547-384c-423033333139"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Connect.Service.Principal.App.Models.V1.CollectivePropertiesRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connect.Service.Principal.App.Models.V1.Collective"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connect.Errors.Results.ConnectApiErrorResult"
                }
              }
            }
          }
        }
      }
    },
    "/v1/entities/{entityId}/permissions": {
      "post": {
        "tags": [
          "Entities"
        ],
        "summary": "Add permissions to an Entity",
        "description": "Add permissions to an Entity",
        "operationId": "AddPermissionToEntityEndpoint",
        "parameters": [
          {
            "name": "entityId",
            "in": "path",
            "description": "The id of the Entity",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "5a554157-5a5a-4547-384c-423033333139"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Connect.Service.Principal.App.Models.V1.EntityPermissionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connect.Errors.Results.ConnectApiErrorResult"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Entities"
        ],
        "summary": "List permissions by Entity",
        "description": "Returns a page listing the permissions associated with this Entity",
        "operationId": "ListEntityPermissionsEndpoint",
        "parameters": [
          {
            "name": "entityId",
            "in": "path",
            "description": "The id of the Entity",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "5a554157-5a5a-4547-384c-423033333139"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connect.Service.Principal.App.Models.V1.PagedPermissions"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connect.Errors.Results.ConnectApiErrorResult"
                }
              }
            }
          }
        }
      }
    },
    "/v1/entities/{entityId}/permissions/principals/{principalId}": {
      "delete": {
        "tags": [
          "Entities"
        ],
        "summary": "Remove permission from an Entity",
        "description": "Remove permission from an Entity",
        "operationId": "RemovePermissionFromEntityEndpoint",
        "parameters": [
          {
            "name": "entityId",
            "in": "path",
            "description": "The id of the Entity",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "5a554157-5a5a-4547-384c-423033333139"
          },
          {
            "name": "principalId",
            "in": "path",
            "description": "The id of the Principal",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "permissionLevel",
            "in": "query",
            "description": "Optional, the specific permission level to remove",
            "schema": {
              "$ref": "#/components/schemas/Connect.Service.Principal.App.Models.V1.PermissionLevel"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connect.Errors.Results.ConnectApiErrorResult"
                }
              }
            }
          }
        }
      }
    },
    "/v1/collectives/{collectiveId}/entities": {
      "post": {
        "tags": [
          "Entities"
        ],
        "summary": "Add an Entity to a Collective",
        "description": "Adds an Entity to a Collective and returns that Collective with a list of Entities, including the newly added Entity",
        "operationId": "AddEntityToCollectiveEndpoint",
        "parameters": [
          {
            "name": "collectiveId",
            "in": "path",
            "description": "The id of the Collective",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "5a554157-5a5a-4547-384c-423033333139"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Connect.Service.Principal.App.Models.V1.EntityRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connect.Service.Principal.App.Models.V1.Collective"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connect.Errors.Results.ConnectApiErrorResult"
                }
              }
            }
          }
        }
      }
    },
    "/v1/collectives/{collectiveId}/entities/{entityId}": {
      "delete": {
        "tags": [
          "Entities"
        ],
        "summary": "Remove an Entity from a Collective",
        "description": "Removes an Entity from a Collective and returns that Collective with a list of Entities associated with it",
        "operationId": "RemoveEntityFromCollectiveEndpoint",
        "parameters": [
          {
            "name": "collectiveId",
            "in": "path",
            "description": "The id of the Collective",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "5a554157-5a5a-4547-384c-423033333139"
          },
          {
            "name": "entityId",
            "in": "path",
            "description": "The id of the Entity",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connect.Service.Principal.App.Models.V1.Collective"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connect.Errors.Results.ConnectApiErrorResult"
                }
              }
            }
          }
        }
      }
    },
    "/v1/collectives/{collectiveId}/members": {
      "post": {
        "tags": [
          "Members"
        ],
        "summary": "Add a member to a Collective",
        "description": "Adds a member to a Collective and returns that Collective with a list of members associated with it",
        "operationId": "AddMemberToCollectiveEndpoint",
        "parameters": [
          {
            "name": "collectiveId",
            "in": "path",
            "description": "The id of the Collective",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "5a554157-5a5a-4547-384c-423033333139"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Connect.Service.Principal.App.Models.V1.PrincipalRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connect.Service.Principal.App.Models.V1.Collective"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connect.Errors.Results.ConnectApiErrorResult"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Members"
        ],
        "summary": "List members by Collective",
        "description": "Returns a page listing the members in a Collective",
        "operationId": "ListCollectiveMembersEndpoint",
        "parameters": [
          {
            "name": "collectiveId",
            "in": "path",
            "description": "The id of the Collective",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "5a554157-5a5a-4547-384c-423033333139"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connect.Service.Principal.App.Models.V1.PagedPrincipals"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connect.Errors.Results.ConnectApiErrorResult"
                }
              }
            }
          }
        }
      }
    },
    "/v1/collectives/{collectiveId}/members/{memberId}": {
      "delete": {
        "tags": [
          "Members"
        ],
        "summary": "Remove a member from a Collective",
        "description": "Removes a member from a Collective and returns that Collective with a list of members associated with it",
        "operationId": "RemoveMemberFromCollectiveEndpoint",
        "parameters": [
          {
            "name": "collectiveId",
            "in": "path",
            "description": "The id of the Collective",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "example": "5a554157-5a5a-4547-384c-423033333139"
          },
          {
            "name": "memberId",
            "in": "path",
            "description": "The id of the member",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connect.Service.Principal.App.Models.V1.Collective"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connect.Errors.Results.ConnectApiErrorResult"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Connect.Errors.Results.ConnectApiError": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "message": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "Connect.Errors.Results.ConnectApiErrorResult": {
        "type": "object",
        "properties": {
          "errors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Connect.Errors.Results.ConnectApiError"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "Connect.Models.Links": {
        "type": "object",
        "properties": {
          "next": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "Connect.Models.Meta": {
        "type": "object",
        "properties": {
          "continuationToken": {
            "type": "string",
            "nullable": true
          },
          "pageSize": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "Connect.Service.Principal.App.Models.V1.Collective": {
        "type": "object",
        "properties": {
          "entities": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The Entities of the Collective",
            "nullable": true
          },
          "id": {
            "type": "string",
            "description": "The id of the Collective",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "description": "The name of the Collective",
            "nullable": true
          },
          "owner": {
            "type": "string",
            "description": "The owner of the Collective",
            "format": "uuid"
          },
          "properties": {
            "description": "The custom properties of the Collective",
            "nullable": true
          },
          "type": {
            "$ref": "#/components/schemas/Connect.Service.Principal.Core.Models.CollectiveType"
          }
        },
        "additionalProperties": false,
        "description": "A Collective"
      },
      "Connect.Service.Principal.App.Models.V1.CollectivePropertiesRequest": {
        "type": "object",
        "properties": {
          "properties": {
            "description": "The custom properties of the Collective",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A request to modify the custom properties of a Collective"
      },
      "Connect.Service.Principal.App.Models.V1.CollectiveRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The name of the Collective",
            "nullable": true
          },
          "type": {
            "$ref": "#/components/schemas/Connect.Service.Principal.Core.Models.CollectiveType"
          }
        },
        "additionalProperties": false,
        "description": "A request to modify a Collective"
      },
      "Connect.Service.Principal.App.Models.V1.CreateCollectiveRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "collectiveId": {
            "type": "string",
            "description": "The id of the Collective",
            "format": "uuid",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The name of the Collective",
            "nullable": true
          },
          "owner": {
            "type": "string",
            "description": "The owner of the Collective",
            "format": "uuid",
            "nullable": true
          },
          "properties": {
            "description": "The custom properties of the Collective",
            "nullable": true
          },
          "type": {
            "$ref": "#/components/schemas/Connect.Service.Principal.Core.Models.CollectiveType"
          }
        },
        "additionalProperties": false,
        "description": "Represents a request to create a collective."
      },
      "Connect.Service.Principal.App.Models.V1.EntityPermissionRequest": {
        "type": "object",
        "properties": {
          "permissionLevel": {
            "$ref": "#/components/schemas/Connect.Service.Principal.App.Models.V1.PermissionLevel"
          },
          "principalId": {
            "type": "string",
            "description": "The id of the Principal",
            "format": "uuid"
          }
        },
        "additionalProperties": false,
        "description": "A request to add permissions"
      },
      "Connect.Service.Principal.App.Models.V1.EntityRequest": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The id of the Entity",
            "format": "uuid",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A request to add an Entity"
      },
      "Connect.Service.Principal.App.Models.V1.PagedCollectives": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Connect.Service.Principal.App.Models.V1.Collective"
            },
            "nullable": true
          },
          "links": {
            "$ref": "#/components/schemas/Connect.Models.Links"
          },
          "meta": {
            "$ref": "#/components/schemas/Connect.Models.Meta"
          }
        },
        "additionalProperties": false,
        "description": "A page of Collectives"
      },
      "Connect.Service.Principal.App.Models.V1.PagedPermissions": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Connect.Service.Principal.App.Models.V1.Permission"
            },
            "nullable": true
          },
          "links": {
            "$ref": "#/components/schemas/Connect.Models.Links"
          },
          "meta": {
            "$ref": "#/components/schemas/Connect.Models.Meta"
          }
        },
        "additionalProperties": false,
        "description": "A page of permissions"
      },
      "Connect.Service.Principal.App.Models.V1.PagedPrincipals": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Connect.Service.Principal.App.Models.V1.Principal"
            },
            "nullable": true
          },
          "links": {
            "$ref": "#/components/schemas/Connect.Models.Links"
          },
          "meta": {
            "$ref": "#/components/schemas/Connect.Models.Meta"
          }
        },
        "additionalProperties": false,
        "description": "A page of Principals"
      },
      "Connect.Service.Principal.App.Models.V1.Permission": {
        "type": "object",
        "properties": {
          "entityId": {
            "type": "string",
            "description": "The id of the Entity",
            "format": "uuid"
          },
          "id": {
            "type": "string",
            "description": "The id",
            "format": "uuid"
          },
          "permissionLevels": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Connect.Service.Principal.App.Models.V1.PermissionLevel"
            },
            "description": "The permission levels",
            "nullable": true
          },
          "principalId": {
            "type": "string",
            "description": "The id of the Principal",
            "format": "uuid"
          }
        },
        "additionalProperties": false,
        "description": "A permission"
      },
      "Connect.Service.Principal.App.Models.V1.PermissionLevel": {
        "enum": [
          "Viewer",
          "Contributor",
          "Administer",
          "Owner"
        ],
        "type": "string",
        "description": "The available Permission Levels."
      },
      "Connect.Service.Principal.App.Models.V1.Principal": {
        "type": "object",
        "properties": {
          "emailAddress": {
            "type": "string",
            "description": "The email address of the Principal",
            "nullable": true
          },
          "id": {
            "type": "string",
            "description": "The id",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "description": "The name of the Principal",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A Principal"
      },
      "Connect.Service.Principal.App.Models.V1.PrincipalRequest": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The id of the Principal",
            "format": "uuid",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A request to add a Principal"
      },
      "Connect.Service.Principal.Core.Models.CollectiveType": {
        "enum": [
          "Fleet",
          "SolarFarm",
          "VirtualPowerPlant"
        ],
        "type": "string"
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "description": "Access Token Authentication",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  },
  "security": [
    {
      "bearerAuth": [ ]
    }
  ]
}