openapi: 3.0.0 info: version: 2.0.0 termsOfService: https://exoscale.com/terms contact: email: support@exoscale.com name: Exoscale Support url: https://portal.exoscale.com/tickets title: Exoscale ai-api-key organization API description: Infrastructure automation API, allowing programmatic access to all Exoscale products and services. servers: - url: https://api-{zone}.exoscale.com/v2 variables: zone: default: ch-gva-2 enum: - ch-gva-2 - ch-dk-2 - de-fra-1 - de-muc-1 - at-vie-1 - at-vie-2 - bg-sof-1 - hr-zag-1 tags: - name: organization paths: /usage-report: get: tags: - organization responses: '200': description: '200' content: application/json: schema: type: object properties: usage: type: array items: type: object properties: from: type: string readOnly: true description: Period Start Date to: type: string readOnly: true description: Period End Date product: type: string readOnly: true description: Product variable: type: string readOnly: true description: Variable description: type: string readOnly: true description: Description quantity: type: string readOnly: true description: Quantity unit: type: string readOnly: true description: Unit description: Usage description: Returns aggregated usage reports for an organization parameters: - in: query required: false name: period schema: type: string summary: Retrieve organization usage reports operationId: get-usage-report /organization: get: tags: - organization responses: '200': description: '200' content: application/json: schema: $ref: '#/components/schemas/organization' description: '' parameters: [] summary: Retrieve an organization operationId: get-organization /env-impact/{period}: get: tags: - organization responses: '200': description: '200' content: application/json: schema: $ref: '#/components/schemas/env-impact-report' description: '[BETA] Returns environmental impact reports for an organization' parameters: - in: path required: true name: period schema: type: string summary: '[BETA] Retrieve organization environmental impact reports' operationId: get-env-impact components: schemas: organization: type: object properties: id: type: string format: uuid readOnly: true description: Organization ID name: type: string readOnly: true description: Organization name address: type: string readOnly: true description: Organization address postcode: type: string readOnly: true description: Organization postcode city: type: string readOnly: true description: Organization city country: type: string readOnly: true description: Organization country balance: type: number readOnly: true description: Organization balance currency: type: string readOnly: true description: Organization currency description: Organization env-product: type: object properties: value: type: string description: Value metadata: type: array items: $ref: '#/components/schemas/env-metadata-entry' description: Metadata impacts: type: array items: $ref: '#/components/schemas/env-impact-indicator' description: Impacts env-metadata-entry: type: object properties: value: type: string description: Value amount: type: number description: Amount unit: type: string description: Unit env-impact-detail: type: object properties: value: type: string description: Value amount: type: number description: Amount unit: type: string description: Unit env-impact-indicator: type: object properties: value: type: string description: Value amount: type: number description: Amount unit: type: string description: Unit details: type: array items: $ref: '#/components/schemas/env-impact-detail' description: Details env-impact-report: type: object properties: metadata: type: array items: $ref: '#/components/schemas/env-metadata-entry' description: Metadata products: type: array items: $ref: '#/components/schemas/env-product' description: Products x-topics: - title: API Request Signature content: ' In order to authenticate legitimate users, the Exoscale API requires incoming requests to be signed using valid Exoscale API account credentials with the following mechanism. ## Signature Mechanism The *message* (i.e. content) to sign contains several segments concatenated using a line return character (`\n`). All segments must be included and in the described order. For cases where a segment doesn''t fit the context of the request (e.g. no request body) **an empty line must be used instead**. * Request method and request URL (path only), separated by a space character * Request body * Request URL parameters (Query String) values, concatenated without separator. The matching parameter names have to be specified in the resulting signature header `signed-query-args=` pragma, separated by semicolons (e.g. `p1;p2;pN`). * Request header values, concatenated without separator (none at the moment, leave empty) * Request expiration date in UNIX timestamp format Example *message* to sign for `GET /v2/resource/a02baf5a-a3e4-49a0-857b-8a08d276c1c0?p1=v1&p2=v2`: ``` GET /v2/resource/a02baf5a-a3e4-49a0-857b-8a08d276c1c0 v1v2 1599140767 ``` The two blank lines above are due to the absence of a request body and signed headers. Example *message* to [create a security group](https://community.exoscale.com/reference/api/compute/security-group/#create-security-group) ``` POST /v2/security-group {"name": "my-security-group"} 1599140767 ``` The two blank lines above are due to the absence of query parameters and signed headers. The request signature consists of the base64-encoded [HMAC](https://en.wikipedia.org/wiki/HMAC) hash of the UTF-8 encoded *message* and the Exoscale API secret using the SHA265 function: ``` signature = BASE64_ENCODE(HMAC_SHA256(Exoscale API secret, message)) ``` Finally, the computed signature must be added to the API request in a `Authorization` header such as: ``` Authorization: EXO2-HMAC-SHA256 credential=,expires=,signature= ``` Example API query: ``` GET /v2/resource/a02baf5a-a3e4-49a0-857b-8a08d276c1c0?p1=v1&p2=v2 HTTP/1.1 Host: api-ch-gva-2.exoscale.com Authorization: EXO2-HMAC-SHA256 credential=EXO29147e9f89102b7ac1e88514,signed-query-args=p1;p2,expires=1599140767,signature=2AOBQsbElQb4FpKT/FM/9T4NobjlmZkSGvvdUth/xlY= ``` ## Reference Implementations You can look up the following existing reference implementations: * Go: [github.com/exoscale/egoscale/api/v2 > `SecurityProviderExoscale.signRequest`](https://github.com/exoscale/egoscale/blob/master/v2/api/security.go) * Python: [requests-exoscale-auth > `ExoscaleV2Auth`](https://github.com/exoscale/requests-exoscale-auth/blob/master/exoscale_auth.py) ' - title: Zone local resources content: ' The API is deployed across all Exoscale zones. When performing a compute call, you should use the relevant zone for your resource. For example: https://api-de-fra-1.exoscale.com/v2/instance would return only the instances from `de-fra-1`, https://api-ch-gva-2.exoscale.com/v2/instance from `ch-gva-2`. To obtain a list of all instances across all zones, you would need to do the corresponding request for each zone. '