> ## 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.

# Archive resource

> Archives a resource, so that `GET /v1/resources` leaves it out unless `includeArchived` is true.

Requires the role `resources:write`.



## OpenAPI

````yaml /api-reference/openapi.yaml post /v1/resources/{id}/archive
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}/archive:
    post:
      tags:
        - Resources
      summary: Archive resource
      description: >-
        Archives a resource, so that `GET /v1/resources` leaves it out unless
        `includeArchived` is true.


        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.
      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 breaks the schema
            of the endpoint.

            - `resource_is_already_archived`: the resource is already archived.
          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
                      - resource_is_already_archived
                  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: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                resource_is_already_archived:
                  value:
                    message: resource is already archived
                    code: resource_is_already_archived
        '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
        '409':
          description: >-
            Other data blocks the action.


            - `resource_has_active_plan_charge`: a plan charge names the
            resource, and `details.references.planCharges` gives the `count` of
            those plan charges and the `sampleNames` of up to three of them.
          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_has_active_plan_charge
                  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_has_active_plan_charge:
                  value:
                    message: >-
                      resource is in use by an active plan charge and cannot be
                      archived
                    code: resource_has_active_plan_charge
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.