> ## Documentation Index
> Fetch the complete documentation index at: https://docs.useaira.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update resource

> Replaces the name, the aggregation, the aggregated property and the filters of a resource, while its type, its item and its billing model stay as they are.

Requires the role `resources:write`.



## OpenAPI

````yaml /api-reference/openapi.yaml put /v1/resources/{id}
openapi: 3.1.0
info:
  title: API Reference
  version: '1.0'
  description: Aira API Reference
  x-logo:
    url: https://static.useaira.com/images/airalogo.svg
    backgroundColor: '#FFFFFF'
    altText: Aira Logo
servers:
  - url: https://api.useaira.com
    description: API base URL
security:
  - ApiKey: []
paths:
  /v1/resources/{id}:
    put:
      tags:
        - Resources
      summary: Update resource
      description: >-
        Replaces the name, the aggregation, the aggregated property and the
        filters of a resource, while its type, its item and its billing model
        stay as they are.


        Requires the role `resources:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the resource in our system.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  description: The name of the resource.
                  type: string
                  example: Emails sent
                aggregation:
                  description: >-
                    How the resource turns the events of a charge period into
                    one number from the aggregated property: their sum (`sum`),
                    the last value (`last_during_period`) or the count of
                    distinct values (`unique`).
                  type: string
                  enum:
                    - sum
                    - last_during_period
                    - unique
                aggregateByField:
                  description: >-
                    The aggregated property: the property of the events that the
                    aggregation reads.
                  type: string
                  example: value
                filters:
                  description: >-
                    The event filters of the resource: the event names and the
                    property values that an event must have to count for the
                    resource. The filters of one property match when any of them
                    matches, and the filters of different properties must all
                    match. At least one filter must have the property
                    `eventName`.
                  type: array
                  items:
                    type: object
                    properties:
                      property:
                        description: >-
                          The property that the filter compares: `eventName`
                          compares the event name, and any other value compares
                          the property of the event with that name. Repeat a
                          property to match any of several values.
                        type: string
                        pattern: ^[a-zA-Z0-9_-]+$
                        example: eventName
                      operator:
                        description: >-
                          How the filter compares the property with the value:
                          `equals`, the default, matches a property that equals
                          the value.
                        type: string
                        enum:
                          - equals
                      value:
                        description: >-
                          The value that the filter compares the property with,
                          as written, with no change of case or accents.
                        type: string
                        example: email_sent
                    required:
                      - property
                      - value
                    additionalProperties: false
                  example:
                    - property: eventName
                      operator: equals
                      value: email_sent
                    - property: type
                      operator: equals
                      value: transactional
                    - property: type
                      operator: equals
                      value: marketing
              required:
                - name
                - aggregation
                - aggregateByField
                - filters
              additionalProperties: false
        required: true
        description: >-
          The name, the aggregation, the aggregated property and the filters
          that replace those of the resource.
      responses:
        '200':
          description: >-
            A resource: a named measure of usage, in units or in money, that
            says which events count and how they add up. A resource has no
            price.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the resource in our system.
                    type: string
                    format: uuid
                  name:
                    description: The name of the resource.
                    type: string
                    example: Emails sent
                  type:
                    description: >-
                      Whether the resource measures usage in units (`unit`) or
                      in money (`currency`).
                    type: string
                    enum:
                      - unit
                      - currency
                  aggregation:
                    description: >-
                      How the resource turns the events of a charge period into
                      one number from the aggregated property: their sum
                      (`sum`), the last value (`last_during_period`) or the
                      count of distinct values (`unique`).
                    type: string
                    enum:
                      - sum
                      - last_during_period
                      - unique
                  aggregateByField:
                    description: >-
                      The aggregated property: the property of the events that
                      the aggregation reads.
                    type: string
                    example: value
                  billingModel:
                    description: >-
                      How the resource reads its values in a charge period:
                      `in_full` takes all the events, and `proration` weighs
                      each value by the days that it was in effect.
                    type: string
                    enum:
                      - in_full
                      - proration
                  itemId:
                    description: >-
                      The id of the item of the resource, the catalog record
                      that names what a charge on the resource bills.
                    type: string
                    format: uuid
                  filters:
                    description: >-
                      The event filters of the resource: the event names and the
                      property values that an event must have to count for the
                      resource. The filters of one `group` match when any of
                      them matches, and every group must match. At least one
                      filter has the property `eventName`.
                    type: array
                    items:
                      type: object
                      properties:
                        property:
                          description: >-
                            The property that the filter compares: `eventName`
                            compares the event name, and any other value
                            compares the property of the event with that name.
                            Repeat a property to match any of several values.
                          type: string
                          pattern: ^[a-zA-Z0-9_-]+$
                          example: eventName
                        operator:
                          description: >-
                            How the filter compares the property with the value:
                            `equals` matches a property that equals the value.
                          type: string
                          enum:
                            - equals
                        value:
                          description: >-
                            The value that the filter compares the property
                            with, as written, with no change of case or accents.
                          type: string
                          example: email_sent
                        group:
                          description: >-
                            The group of the filter, which is its property. The
                            filters of one group match when any of them matches,
                            and every group must match.
                          type: string
                          example: type
                      required:
                        - property
                        - operator
                        - value
                        - group
                      additionalProperties: false
                    example:
                      - property: eventName
                        operator: equals
                        value: email_sent
                        group: eventName
                      - property: type
                        operator: equals
                        value: transactional
                        group: type
                      - property: type
                        operator: equals
                        value: marketing
                        group: type
                  archivedAt:
                    description: >-
                      When the resource was archived, or null when it is not
                      archived.
                    type: string
                    format: date-time
                    nullable: true
                required:
                  - id
                  - name
                  - type
                  - aggregation
                  - aggregateByField
                  - billingModel
                  - itemId
                  - filters
                  - archivedAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `missing_resource_event_name_filter`: no filter of `filters` has
            the `property` `eventName`.

            - `invalid_resource_filter_value`: the `value` of a filter on
            `eventName` holds a character other than a letter, a digit, a hyphen
            or an underscore.

            - `invalid_billing_model_for_resource_aggregation`: the billing
            model of the resource is `proration` and `aggregation` is not
            `last_during_period`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - missing_resource_event_name_filter
                      - invalid_resource_filter_value
                      - invalid_billing_model_for_resource_aggregation
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''name'' is required'
                    code: json_schema_validation_error
                missing_resource_event_name_filter:
                  value:
                    message: resource must have at least one eventName filter
                    code: missing_resource_event_name_filter
                invalid_resource_filter_value:
                  value:
                    message: >-
                      invalid resource filter value '{value}' for property
                      '{property}'. Only alphanumeric characters, hyphens and
                      underscores are allowed
                    code: invalid_resource_filter_value
                invalid_billing_model_for_resource_aggregation:
                  value:
                    message: invalid billing model for resource aggregation
                    code: invalid_billing_model_for_resource_aggregation
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the tenant does not allow the IP of the request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role resources:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist in the tenant.

            - `resource_not_found`: no resource of the tenant has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - resource_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                resource_not_found:
                  value:
                    message: resource not found
                    code: resource_not_found
components:
  securitySchemes:
    ApiKey:
      type: apiKey
      description: API Key Authentication.
      name: X-API-KEY
      in: header

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.