flexmeasures.api.v3_0.accounts

Classes

class flexmeasures.api.v3_0.accounts.AccountAPI
auditlog(id: int, account: Account)

— get:

summary: Get the history of actions for a specific account. description: |

This endpoint retrieves a log of historical actions and events associated with the account, identified by its ID.

security:
  • ApiKeyAuth: []

parameters:
  • name: id in: path description: The ID of the account whose history is being requested. required: true schema:

    type: integer format: int32

responses:
200:

description: PROCESSED content:

application/json:
schema:

type: array items:

type: object properties:

event:

type: string description: Description of the action or event that occurred.

event_datetime:

type: string format: date-time description: Timestamp when the event occurred.

active_user_id:

type: integer description: The ID of the user who performed the action.

examples:
account_history_list:

summary: A list of account history events value:

  • event: ‘User test user deleted’ event_datetime: ‘2021-01-01T00:00:00’ active_user_id: 1

  • event: ‘Account name changed to “New Corp”’ event_datetime: ‘2021-01-02T10:30:00’ active_user_id: 5

400:

description: INVALID_REQUEST, REQUIRED_INFO_MISSING, or UNEXPECTED_PARAMS

401:

description: UNAUTHORIZED

403:

description: INVALID_SENDER

422:

description: UNPROCESSABLE_ENTITY

tags:
  • Accounts

get(id: int, account: Account)

— get:

summary: Fetch one account. description: |

This endpoint retrieves a single account, given its ID in the path. Access is restricted: only admins, consultants, and users belonging to the account itself are authorized to use this endpoint.

security:
  • ApiKeyAuth: []

parameters:
  • name: id in: path description: The ID of the account to retrieve. required: true schema:

    type: integer format: int32

responses:
200:

description: PROCESSED content:

application/json:
example:

id: 1 name: Test Account account_roles: [1, 3] consultancy_account_id: 2

400:

description: INVALID_REQUEST, REQUIRED_INFO_MISSING, or UNEXPECTED_PARAMS

401:

description: UNAUTHORIZED

403:

description: INVALID_SENDER

422:

description: UNPROCESSABLE_ENTITY

tags:
  • Accounts

index(page: int | None = None, per_page: int | None = None, filter: list[str] | None = None, sort_by: str | None = None, sort_dir: str | None = None)

— get:

summary: List all accounts accessible to the current user. description: |

This endpoint returns all accounts the current user has access to. Accessible accounts include the user’s own account, accounts for which the user is a consultant, and all accounts if the user has admin privileges.

The endpoint supports pagination of the account list using the page and per_page query parameters.
  • If the page parameter is not provided, all accounts are returned, without pagination information. The result will be a list of accounts.

  • If a page parameter is provided, the response will be paginated, showing a specific number of accounts per page as defined by per_page (default is 10).

  • If a search ‘filter’ such as ‘solar “ACME corp”’ is provided, the response will filter out accounts where each search term is either present in their name.

The response schema for pagination is inspired by [DataTables](https://datatables.net/manual/server-side#Returned-data)

security:
  • ApiKeyAuth: []

parameters:
  • in: query schema: AccountAPIQuerySchema

responses:
200:

description: PROCESSED content:

application/json:
examples:
single_account:

summary: One account being returned (no pagination requested) value:

  • id: 1 name: Test Account account_roles: [1, 3] consultancy_account_id: 2 primary_color: ‘#1a3443’ secondary_color: ‘#f1a122’ logo_url: ‘https://example.com/logo.png

paginated_accounts:

summary: A paginated list of accounts being returned value:

data:
  • id: 1 name: Test Account account_roles: [1, 3] consultancy_account_id: 2 primary_color: ‘#1a3443’ secondary_color: ‘#f1a122’ logo_url: ‘https://example.com/logo.png

num-records: 1 filtered-records: 1

400:

description: INVALID_REQUEST

401:

description: UNAUTHORIZED

403:

description: INVALID_SENDER

422:

description: UNPROCESSABLE_ENTITY

tags:
  • Accounts

patch(account_data: dict, id: int, account: Account)

— patch:

summary: Update an existing account. description: |

This endpoint updates the details for an existing account.

In the JSON body, sent in only the fields you want to update.

Restrictions on Fields: - The id field is read-only and cannot be updated. - The consultancy_account_id field can only be edited if the current user has an admin role.

security:
  • ApiKeyAuth: []

parameters:
  • name: id in: path description: The ID of the account to update. required: true schema:

    type: integer format: int32

requestBody:

description: Account data to be updated. required: true content:

application/json:

schema: AccountSchema example:

name: Test Account Updated primary_color: ‘#1a3443’ secondary_color: ‘#f1a122’ logo_url: ‘https://example.com/logo.png’ consultancy_account_id: 2

responses:
200:

description: UPDATED (The entire updated account object is returned) content:

application/json:
example:

id: 1 name: Test Account Updated account_roles: [1, 3] primary_color: ‘#1a3443’ secondary_color: ‘#f1a122’ logo_url: ‘https://example.com/logo.png’ consultancy_account_id: 2

400:

description: INVALID_REQUEST, REQUIRED_INFO_MISSING, or UNEXPECTED_PARAMS

401:

description: UNAUTHORIZED

403:

description: INVALID_SENDER

422:

description: UNPROCESSABLE_ENTITY (e.g., trying to update ‘consultancy_account_id’ without admin rights)

tags:
  • Accounts