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

# Get usage history

> Retrieves historical usage data for a customer's metered feature over time.



## OpenAPI

````yaml https://app.stainless.com/api/spec/documented/stigg/openapi.documented.yml get /api/v1/usage/{customerId}/history/{featureId}
openapi: 3.0.0
info:
  title: Stigg API
  description: Stigg API documentation
  version: 7.93.1
  contact: {}
servers:
  - url: https://api.stigg.io
    description: Production
security:
  - ApiKeyAuth: []
tags:
  - name: Customers
    description: Operations related to customers
  - name: Subscriptions
    description: Operations related to subscriptions
  - name: Coupons
    description: Operations related to coupons
  - name: Bulk Import
    description: Operations related to import of customers and subscriptions
  - name: Usage
    description: Operations related to usage & metering
  - name: Promotional Entitlements
    description: Operations related to promotional entitlements
  - name: Products
    description: Operations related to products
  - name: Features
    description: Operations related to features
  - name: Addons
    description: Operations related to addons
  - name: Plans
    description: Operations related to plans
  - name: Credit grants
    description: Operations related to credit grants
  - name: Credit ledger
    description: Operations related to credit ledger
  - name: Custom currencies
    description: Operations related to custom currencies
paths:
  /api/v1/usage/{customerId}/history/{featureId}:
    get:
      tags:
        - Usage
      summary: Get usage history
      description: >-
        Retrieves historical usage data for a customer's metered feature over
        time.
      operationId: UsageHistoryController_getUsageHistory
      parameters:
        - name: customerId
          required: true
          in: path
          description: Customer id
          schema:
            minLength: 1
            maxLength: 255
            pattern: ^[a-zA-Z0-9][a-zA-Z0-9_|.@-]*$
            type: string
        - name: featureId
          required: true
          in: path
          description: Feature id
          schema:
            minLength: 1
            maxLength: 255
            pattern: ^[a-zA-Z0-9][a-zA-Z0-9_|.-]*$
            type: string
        - name: resourceId
          required: false
          in: query
          description: Resource id
          schema:
            minLength: 1
            maxLength: 255
            pattern: ^[a-zA-Z0-9][a-zA-Z0-9_|.-]*$
            nullable: true
            type: string
        - name: startDate
          required: true
          in: query
          description: The start date of the range
          schema:
            format: date-time
            type: string
        - name: endDate
          required: false
          in: query
          description: The end date of the range
          schema:
            format: date-time
            type: string
        - name: groupBy
          required: false
          in: query
          description: Criteria by which to group the usage history
          schema:
            maxLength: 255
            type: string
        - name: X-ACCOUNT-ID
          in: header
          description: >-
            Account ID — optional when authenticating with a user JWT (Bearer
            token); falls back to the user's first membership. Ignored for
            API-key auth.
          required: false
          schema:
            type: string
        - name: X-ENVIRONMENT-ID
          in: header
          description: >-
            Environment ID — required when authenticating with a user JWT
            (Bearer token) on environment-scoped endpoints. Ignored for API-key
            auth (env is intrinsic to the key).
          required: false
          schema:
            type: string
      responses:
        '200':
          description: Usage history data points for the specified period.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageHistoryResponseDto'
        '400':
          description: bad request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadInputErrorResponseDto'
        '401':
          description: User is not authenticated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthenticatedErrorResponseDto'
        '403':
          description: User is not allowed to access this resource.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ForbiddenErrorResponseDto'
        '404':
          description: Usage history not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundErrorResponseDto'
        '429':
          description: Too many requests.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TooManyRequestsErrorResponseDto'
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Stigg from '@stigg/typescript';

            const client = new Stigg({
              apiKey: process.env['STIGG_API_KEY'], // This is the default and can be omitted
            });

            const response = await client.v1.usage.history('featureId', {
              customerId: 'customerId',
              startDate: '2019-12-27T18:11:19.117Z',
            });

            console.log(response.data);
        - lang: Python
          source: |-
            import os
            from datetime import datetime
            from stigg import Stigg

            client = Stigg(
                api_key=os.environ.get("STIGG_API_KEY"),  # This is the default and can be omitted
            )
            response = client.v1.usage.history(
                feature_id="featureId",
                customer_id="customerId",
                start_date=datetime.fromisoformat("2019-12-27T18:11:19.117"),
            )
            print(response.data)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/stiggio/stigg-go\"\n\t\"github.com/stiggio/stigg-go/option\"\n)\n\nfunc main() {\n\tclient := stigg.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tresponse, err := client.V1.Usage.History(\n\t\tcontext.TODO(),\n\t\t\"featureId\",\n\t\tstigg.V1UsageHistoryParams{\n\t\t\tCustomerID: \"customerId\",\n\t\t\tStartDate:  time.Now(),\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\n}\n"
        - lang: Java
          source: |-
            package io.stigg.example;

            import io.stigg.client.StiggClient;
            import io.stigg.client.okhttp.StiggOkHttpClient;
            import io.stigg.models.v1.usage.UsageHistoryParams;
            import io.stigg.models.v1.usage.UsageHistoryResponse;
            import java.time.OffsetDateTime;

            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    StiggClient client = StiggOkHttpClient.fromEnv();

                    UsageHistoryParams params = UsageHistoryParams.builder()
                        .customerId("customerId")
                        .featureId("featureId")
                        .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
                        .build();
                    UsageHistoryResponse response = client.v1().usage().history(params);
                }
            }
        - lang: Ruby
          source: >-
            require "stigg"


            stigg = Stigg::Client.new(api_key: "My API Key")


            response = stigg.v1.usage.history("featureId", customer_id:
            "customerId", start_date: "2019-12-27T18:11:19.117Z")


            puts(response)
        - lang: C#
          source: |-
            using System;
            using Stigg.Client;
            using Stigg.Client.Models.V1.Usage;

            StiggClient client = new();

            UsageHistoryParams parameters = new()
            {
                CustomerID = "customerId",
                FeatureID = "featureId",
                StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
            };

            var response = await client.V1.Usage.History(parameters);

            Console.WriteLine(response);
        - lang: CLI
          source: |-
            stigg v1:usage history \
              --api-key 'My API Key' \
              --customer-id customerId \
              --feature-id featureId \
              --start-date "'2019-12-27T18:11:19.117Z'"
components:
  schemas:
    UsageHistoryResponseDto:
      type: object
      properties:
        data:
          type: object
          properties:
            series:
              type: array
              items:
                type: object
                properties:
                  tags:
                    type: array
                    items:
                      type: object
                      properties:
                        key:
                          type: string
                          maxLength: 255
                          description: Key of the tag
                        value:
                          type: string
                          maxLength: 255
                          description: Value of the tag
                      required:
                        - key
                        - value
                      title: UsageHistorySeriesTag
                      description: Grouping tag key-value
                    description: Tags for the usage history series
                  points:
                    type: array
                    items:
                      type: object
                      properties:
                        timestamp:
                          type: string
                          format: date-time
                          description: Timestamp of the usage history point
                        value:
                          type: number
                          description: Value of the usage history point
                        isResetPoint:
                          type: boolean
                          description: >-
                            Indicates whether there was usage reset in this
                            point, see `markers` for details
                      required:
                        - timestamp
                        - value
                        - isResetPoint
                      title: UsageHistoryPoint
                      description: Single usage data point
                    description: Points in the usage history series
                required:
                  - tags
                  - points
                title: UsageHistorySeries
                description: Usage data points with tags
              description: Series of usage history
            markers:
              type: array
              items:
                type: object
                properties:
                  type:
                    type: string
                    enum:
                      - PERIODIC_RESET
                      - SUBSCRIPTION_CHANGE_RESET
                    description: Type of marker for a usage history point
                  timestamp:
                    type: string
                    format: date-time
                    description: Timestamp of the marker
                required:
                  - type
                  - timestamp
                title: UsageMarker
                description: Usage reset or change marker
              description: Markers for events that affecting feature usage
          required:
            - series
            - markers
          title: UsageHistory
          description: Historical usage time series
      required:
        - data
      title: Response
      description: Response object
    BadInputErrorResponseDto:
      type: object
      properties:
        message:
          type: string
        code:
          type: string
          enum:
            - BadUserInput
            - DuplicateIntegrationNotAllowed
            - EntityIsArchivedError
            - IntegrityViolation
            - FreePlanCantHaveCompatiblePackageGroupError
            - SubscriptionMustHaveSinglePlanError
            - AddonIsCompatibleWithPlan
            - AddonIsCompatibleWithGroup
            - DuplicateAddonProvisionedError
            - ScheduledMigrationAlreadyExistsError
            - SubscriptionAlreadyOnLatestPlan
            - EntityIdDifferentFromRefIdError
            - UnsupportedFeatureType
            - UnsupportedVendorIdentifier
            - UnsupportedSubscriptionScheduleType
            - InvalidEntitlementResetPeriod
            - IncompatibleSubscriptionAddon
            - UnPublishedPackage
            - MeteringNotAvailableForFeatureType
            - AuthCustomerMismatch
            - AuthCustomerReadonly
            - FetchAllCountriesPricesNotAllowed
            - MemberInvitationError
            - PlansCircularDependencyError
            - NoFeatureEntitlementInSubscription
            - CheckoutIsNotSupported
            - UnsupportedParameter
            - PricingModelNotSupportedByBillingIntegration
            - BillingIntegrationMissing
            - BillingIntegrationAlreadyExistsError
            - InvalidMemberDelete
            - PackageAlreadyPublished
            - DraftPlanCantBeArchived
            - DraftAddonCantBeArchived
            - PlanWithChildCantBeDeleted
            - PlanCannotBePublishWhenBasePlanIsDraft
            - PlanCannotBePublishWhenCompatibleAddonIsDraft
            - PlanIsUsedAsDefaultStartPlan
            - PlanIsUsedAsDowngradePlan
            - InvalidAddressError
            - InvalidQuantity
            - BillingPeriodMissingError
            - DowngradeBillingPeriodNotSupportedError
            - CustomerAlreadyUsesCouponError
            - CustomerAlreadyHaveCustomerCoupon
            - SubscriptionAlreadyCanceledOrExpired
            - TrialMustBeCancelledImmediately
            - SubscriptionDoesNotHaveBillingPeriod
            - InvalidCancellationDate
            - FailedToImportCustomer
            - FailedToImportSubscriptions
            - PackagePricingTypeNotSet
            - InvalidSubscriptionStatus
            - InvalidArgumentError
            - EditAllowedOnDraftPackageOnlyError
            - ResyncAlreadyInProgress
            - ArchivedCouponCantBeApplied
            - ImportAlreadyInProgress
            - AddonHasToHavePriceError
            - SelectedBillingModelDoesntMatchImportedItemError
            - CannotArchiveProductError
            - CannotUnarchiveProductError
            - CannotDeleteCustomerError
            - CannotRemovePaymentMethodFromCustomerError
            - CannotDeleteFeatureError
            - CannotArchiveFeatureError
            - InvalidUpdatePriceUnitAmountError
            - ExperimentAlreadyRunning
            - ExperimentStatusError
            - OperationNotAllowedDuringInProgressExperiment
            - EntitlementsMustBelongToSamePackage
            - CanNotUpdateEntitlementsFeatureGroup
            - MeterMustBeAssociatedToMeteredFeature
            - CannotEditPackageInNonDraftMode
            - CannotAddOverrideEntitlementToPlan
            - MissingEntityIdError
            - NoProductsAvailable
            - PromotionCodeNotForCustomer
            - PromotionCodeNotActive
            - PromotionCodeMaxRedemptionsReached
            - PromotionCodeMinimumAmountNotReached
            - PromotionCodeCustomerNotFirstPurchase
            - AddonWithDraftCannotBeDeletedError
            - CannotReportUsageForEntitlementWithMeterError
            - RecalculateEntitlementsError
            - ImportSubscriptionsBulkError
            - InvalidMetadataError
            - CannotUpsertToPackageThatHasDraft
            - IntegrationValidationError
            - AwsMarketplaceIntegrationValidationError
            - AwsMarketplaceIntegrationError
            - DataExportIntegrationError
            - HubspotIntegrationError
            - DuplicateProductValidationError
            - AmountTooLarge
            - CustomerHasNoEmailAddress
            - MergeEnvironmentValidationError
            - EntitlementLimitExceededError
            - EntitlementUsageOutOfRangeError
            - UsageMeasurementDiffOutOfRangeError
            - AddonQuantityExceedsLimitError
            - AddonDependencyMissingError
            - PackageGroupMinItemsError
            - CannotUpdateUnitTransformationError
            - SingleSubscriptionCantBeAutoCancellationTargetError
            - MultiSubscriptionCantBeAutoCancellationSourceError
            - ChangingPayingCustomerIsNotSupportedError
            - RequiredSsoAuthenticationError
            - InvalidDoggoSignatureError
            - InvalidReceivedSignatureError
            - CannotDeleteDefaultIntegration
            - CannotChangeBillingIntegration
            - FailedToResolveBillingIntegration
            - WorkflowTriggerNotFound
            - DeprecatedEstimateSubscriptionError
            - FeatureConfigurationExceededLimitError
            - FeatureNotBelongToFeatureGroupError
            - FeatureGroupMissingFeaturesError
            - VersionExceedsMaxValueError
            - CannotUpdateExpireAtForExpiredCreditGrantError
            - ExpireAtMustBeLaterThanEffectiveAtError
            - OfferAlreadyExists
            - DraftAlreadyExists
            - CreditGrantAlreadyVoided
            - CreditGrantCannotBeVoided
            - InvalidTaxId
            - ObjectAlreadyBeingUsedByAnotherRequestError
            - TooManySubscriptionsPerCustomer
            - TooManyCustomCurrencies
            - StripeError
            - SchedulingAtEndOfBillingPeriod
            - ApiKeyExpired
            - ApiKeyHasExpiry
          nullable: true
      required:
        - message
        - code
    UnauthenticatedErrorResponseDto:
      type: object
      properties:
        message:
          type: string
        code:
          type: string
          enum:
            - Unauthenticated
          nullable: true
      required:
        - message
        - code
    ForbiddenErrorResponseDto:
      type: object
      properties:
        message:
          type: string
        code:
          type: string
          enum:
            - IdentityForbidden
            - AccessDeniedError
            - NoFeatureEntitlementError
            - GovernanceNotEnabled
          nullable: true
      required:
        - message
        - code
    NotFoundErrorResponseDto:
      type: object
      properties:
        message:
          type: string
        code:
          type: string
          enum:
            - CustomerNotFound
            - CustomCurrencyNotFound
            - CreditGrantNotFound
            - MemberNotFound
            - PackageGroupNotFound
            - AddonNotFound
            - AddonsNotFound
            - EnvironmentMissing
            - IntegrationNotFound
            - VendorIsNotSupported
            - CouponNotFound
            - FutureUpdateNotFound
            - CustomerNoBillingId
            - SubscriptionNoBillingId
            - StripeCustomerIsDeleted
            - InitStripePaymentMethodError
            - PreparePaymentMethodFormError
            - AccountNotFoundError
            - ExperimentNotFoundError
            - NoDraftOfferFound
            - PromotionCodeNotFound
            - FailedToCreateCheckoutSessionError
            - PaymentMethodNotFoundError
            - ProductNotFoundError
            - ProductNotPublishedError
            - MissingBillingInvoiceError
            - BillingInvoiceStatusError
            - FeatureGroupNotFoundError
            - CannotArchiveFeatureGroupError
            - OfferNotFound
            - CustomerResourceNotFound
            - FeatureNotFound
            - PriceNotFound
            - NoActiveSubscriptionForCustomer
            - PlanNotFound
            - PromotionalEntitlementNotFoundError
            - SubscriptionNotFound
            - ApiKeyNotFound
          nullable: true
      required:
        - message
        - code
    TooManyRequestsErrorResponseDto:
      type: object
      properties:
        message:
          type: string
        code:
          type: string
          enum:
            - RateLimitExceeded
          nullable: true
      required:
        - message
        - code
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
      description: Server API Key

````