AWS MARKETPLACE PUBLISHER

Testing and integration

AWS Marketplace Metering Not Accepted? Debug BatchMeterUsage Results

Published: Updated:

Key takeaways

When usage sent with AWS Marketplace BatchMeterUsage is not accepted, investigate by splitting where the failure occurred into three places: an error from the API call itself, the per-record Status in Results of an HTTP 200 response, and UnprocessedRecords in the response. AWS advises retrying for UnprocessedRecords and InternalServiceErrorException in its API reference for BatchMeterUsage, and for the temporary failures (such as InternalFailure) on its common errors page. In addition to these, we at Anti-Pattern Inc., the provider of Deshima, recommend resending with the same content for ThrottlingException and for cases where no response was received, because identical requests are idempotent. For TimestampOutOfBoundsException, remove the expired records and resend the rest. Do not resend DuplicateRecord or CustomerNotSubscribed; investigate your own submission ledger and license ledger, AWS CloudTrail, and the history of events received through Amazon EventBridge instead. Even if you resend with a different quantity, the first quantity is the one used for billing. Recording each diagnosis in the submission ledger, and not updating the quantity of a record whose outcome you do not know, are also handling that we recommend.

Editorial information. This article was translated into English by AI from Deshima’s Japanese article; it has not been reviewed or certified by AWS. AWS documentation linked in this article was current as of November 15, 2026. This article is published by Anti-Pattern Inc., the provider of Deshima; recommendations marked as ours are our own, not AWS guidance.

Suppose BatchMeterUsage returned HTTP 200, but that hour's usage did not show up in billing. No exception appeared in your submission code. There can still be records that were not accepted, because BatchMeterUsage returns whether the call succeeded and whether each record was accepted in separate places. When you find a record that was not accepted, decide from where its result appeared in the response whether to resend it unchanged or to investigate your ledger without sending. Once AWS has accepted a quantity, resending with a changed quantity cannot correct it. (AWS's API reference, AWS's seller guide)

Scope: This article covers integrations that call BatchMeterUsage in AWS Marketplace Metering Service for SaaS Subscription (a usage-based pricing model that bills according to hourly usage) and for the usage portion of SaaS Contract with Consumption (a pricing model that bills overage on a usage basis in addition to the contract price). New SaaS products created on or after June 1, 2026 support Concurrent Agreements (multiple simultaneous agreements for the same product) and send records that specify the buyer with CustomerAWSAccountId and the agreement with LicenseArn. (AWS's API reference, the migration guide on the AWS Marketplace blog) In this article, we call this way of sending the "LicenseArn method," and the way earlier products send with CustomerIdentifier and ProductCode the "ProductCode method." The article assumes the LicenseArn method and notes differences from the ProductCode method where needed. The AWS specifications described here reflect the official documentation as of November 15, 2026. Handling labeled "our proposal" is a design we at Anti-Pattern Inc. recommend based on AWS's specifications. Before adopting it, verify the behavior with a product in Limited visibility.

Incident investigation uses two tables kept in your own database.

  • Submission ledger: a table that stores each usage record you send as one row per license, buyer, hour, and dimension. It holds the quantity to send, the submission result, and the MeteringRecordId (the identifier for each metering record, included in the response)
  • License ledger: a table that stores, for each tenant, the assigned LicenseArn, the buyer's AWS account ID, and the usage start date

"Finalizing" usage means closing the aggregation for one hour and deciding the quantity to send for that hour. The full implementation, including when to finalize quantities, how to design the submission ledger's columns, and final submission when an agreement ends, is covered in AWS Marketplace metering implementation.

Where in the response to look to know a record was accepted

HTTP 200 shows only that the API call succeeded. Per-record results go in Results in the response, which lists both accepted records and invalid records. (AWS's API reference) Status is one of Success, CustomerNotSubscribed, or DuplicateRecord, and only Success indicates acceptance. (AWS's API reference) An implementation that marks records as sent based on HTTP 200 alone misses records that were not accepted.

An HTTP 200 response also has UnprocessedRecords. It is a list of records not processed because of a service-side error, and you can use it as input to retry as is. (AWS's API reference)

When the call itself fails, an exception is returned and no per-record results arrive. At this point you might think, "a 400-series error is pointless to resend unless you fix something." However, ThrottlingException is also an HTTP 400 exception, and among the exceptions that the BatchMeterUsage reference lists, the one with HTTP 500 is InternalServiceErrorException. (AWS's API reference) In addition, these AWS common errors can be returned: InternalFailure (HTTP 500), ServiceUnavailable (HTTP 503), RequestTimeoutException (HTTP 408), and ValidationError (HTTP 400). (AWS's common errors) This list is common to AWS Marketplace APIs, and AWS's API reference for BatchMeterUsage does not list them individually as exceptions that BatchMeterUsage returns. Handling errors uniformly by status code turns even temporary failures caused by call throttling into unsendable records. Decide whether to resend by the name of the exception.

Diagnostic table: where to check and whether to resend, by result

When you receive an incident report, find the row for the result you observed, check the "Ledger or log to check" for that row, and then decide which of the four treatments applies.

  • Accepted: do not resend
  • Resend unchanged: resend after an interval without changing the record's content
  • Remove expired and resend: remove expired records from the batch and resend the rest unchanged. The expired records themselves are not resent
  • Do not resend; investigate: do not resend automatically; a person decides the treatment after checking the ledger and logs
Observed resultLocationAWS's descriptionLedger or log to checkResend decision
Status: SuccessResultsThe record was accepted (AWS's API reference)Store the MeteringRecordId in the submission ledgerAccepted
Status: Success, but the quantity in the response record differs in value from the quantity sentResults―The finalized quantity in the submission ledger and the UsageRecord in the responseDo not resend; investigate
Status: DuplicateRecordResultsA record with a different quantity for the same customer, dimension, and time exists earlier (AWS's API reference)Past submissions for the same combination in the submission ledger, AWS CloudTrail, the sending processDo not resend; investigate
Status: CustomerNotSubscribedResultsThe identifier is invalid, there is no active agreement, or the account is suspended (AWS's API reference)License ledger, history of events received through Amazon EventBridgeDo not resend; investigate
Included in UnprocessedRecordsUnprocessedRecordsUnprocessed because of a service-side error. You can retry with this list (AWS's API reference)The finalized quantity in the submission ledgerResend unchanged
A record you sent is in neither Results nor UnprocessedRecords――The submission ledger and the number of records in the responseResend unchanged
ThrottlingException (HTTP 400)API callThe call was throttled (AWS's API reference)Call frequency and concurrencyResend unchanged
InternalServiceErrorException (HTTP 500)API callInternal error. AWS advises retrying (AWS's API reference)Whether the same exception keeps occurring in the submission job's error logResend unchanged
No response (timeout, dropped connection)API callIdentical requests are idempotent and can be retried (AWS's API reference)The finalized quantity in the submission ledgerResend unchanged
InternalFailure (HTTP 500), ServiceUnavailable (HTTP 503), RequestTimeoutException (HTTP 408)API callInternalFailure is a problem with the internal server, and ServiceUnavailable means the service is temporarily unavailable; AWS advises retrying later for both. RequestTimeoutException means the server did not receive the whole request within the expected time; AWS advises retrying (AWS's common errors)Whether the same exception keeps occurring in the submission job's error logResend unchanged
ValidationError (HTTP 400)API callThe input does not satisfy the required format or constraints (AWS's common errors). That description does not let us tell whether it is the same failure as the quantity-format checksThe result of your pre-submission checks and the content of the requestDo not resend the offending record; investigate. Resend the rest unchanged
TimestampOutOfBoundsException (HTTP 400)API callIf even one record is out of range, the entire batch is not processed. Remove out-of-range records and retry (AWS's API reference)Each record's Timestamp and send time, job delaysRemove expired and resend
InvalidLicenseException (HTTP 400)API callThe LicenseArn is invalid, does not match the customer, or is outside its validity period (AWS's API reference)Mapping to tenants in the license ledger, license start and endDo not resend the offending record; investigate. Resend the rest unchanged
InvalidUsageDimensionException, InvalidUsageAllocationsException, InvalidTagException (HTTP 400)API callErrors in the dimension name, the total of allocations and the quantity type, or tags (AWS's API reference)The product's dimension settings, allocation calculationDo not resend the offending record; investigate. Resend the rest unchanged
Quantity and QuantityAsDecimal specified in the same record, or an allocation quantity whose type does not match the recordAPI callIf even one record breaks a condition that AWS lists as a check, the whole request fails and no record is processed (AWS's API reference). That description does not let us tell the name of the exception that is returnedThe result of your pre-submission checks and the quantity type in the ledgerFix the offending record and send it (the fixed value becomes the new finalized quantity). Resend the rest unchanged
No error, but the usage was recorded against another agreement of the same buyer――The tenant-to-LicenseArn mapping in the license ledgerDo not resend; investigate

AWS's API reference (BatchMeterUsage) advises retrying for two cases: UnprocessedRecords and InternalServiceErrorException. That advice does not cover three cases: ThrottlingException, cases where no response was received, and records that appear nowhere. Of these, for cases where no response was received and records that appear nowhere, you also cannot tell whether AWS processed them. ThrottlingException is an exception indicating that the call was throttled. AWS's common errors page says that the AWS SDKs automatically retry requests that receive this exception, and advises reducing the frequency of requests. (AWS's common errors) Because identical requests are idempotent, we recommend resending all three unchanged. (AWS's API reference) For the common errors InternalFailure, ServiceUnavailable, and RequestTimeoutException, AWS's common errors page advises retrying. That is a different page from the one for BatchMeterUsage, but because identical requests are idempotent, we recommend resending these three unchanged as well.

The handling of a Success with a mismatched quantity in the response, and of usage recorded against another agreement, is also our proposal. AWS compares quantities by value, so if the values are the same, it treats them as matching regardless of whether the response returns the quantity in Quantity or QuantityAsDecimal and in which notation. The public pages do not let us tell which field of the response AWS uses to return the quantity. If the status is Success but the values differ, your own code may be mismatching sent records with the response. Usage recorded against another agreement can occur while still meeting the requirements for avoiding InvalidLicenseException, so stop it with the license ledger before sending.

Record the diagnosis in the submission ledger

Once the diagnostic table has settled the treatment, leave the result in the submission ledger row. With it in the ledger, the next time someone asks about the same hour, you can start investigating without searching for AWS's response again. We recommend giving the ledger's status, in addition to the four that the metering implementation article lists (pending, sent, rejected, expired), an "under investigation" status that marks rows you stop sending automatically. (metering implementation article) The statuses mean the following.

statusMeaning
PendingNot sent yet, or a row to be resent with the same content
SentA row with Success whose response quantity also matches
RejectedA row that you investigated and decided cannot be sent
ExpiredA row past its submission deadline, treated as usage that could not be billed
Under investigationA row that is not sent automatically while you investigate the cause

For a result in which you cannot tell whether the record was processed, do not update the finalized quantity column. The one exception is a record that failed the quantity-format checks: its corrected value is written as the new finalized quantity, because AWS describes that failure as one in which the whole request is not processed.

Observed resultstatusWhat to keep in the ledgerNext submission
Success (response quantity matches)Sentmetering_record_id and sent_atNone
Success (response quantity differs)Under investigationThe quantity sent and the response quantity in last_errorNot sent automatically
DuplicateRecordUnder investigationThe difference from the quantity of the row sent earlier, in last_errorNot sent
CustomerNotSubscribedUnder investigationlast_error, and a mark that the LicenseArn is excluded from sendingStop only that agreement; keep sending the same buyer's other licenses
UnprocessedRecords, ThrottlingException, InternalServiceErrorException, InternalFailure, ServiceUnavailable, RequestTimeoutException (common errors), no response, a record missing from the responsePendingIncrease attempts by 1 and put the result in last_errorResend at an interval with the finalized quantity
Expired record in a TimestampOutOfBoundsExceptionExpiredlast_error, and a mark that it is treated as usage that could not be billedNot sent
In-range record stopped by a TimestampOutOfBoundsExceptionPendingIncrease attempts by 1Remove the expired records and resend
InvalidLicenseException, InvalidUsageDimensionException, ValidationError, and other failures of the whole API callThe offending record is under investigation; the other records are pendingThe exception name in the offending record's last_error. For the other records, increase attempts by 1Do not send the offending record until it is fixed (do not change its quantity). Resend the other records with their finalized quantities

Return an under-investigation row to pending, with its finalized quantity, only when you have decided that it can be sent once the cause is fixed. Mark a row rejected when you investigated and decided it cannot be sent. Do not correct the quantity of a record whose outcome you do not know before returning it to pending. Even when you cannot identify the offending record in a batch, do not make the correct records wait. Once the 24-hour deadline passes (06:00 UTC for the previous month's usage at month-end), the correct records can no longer be billed either. This handling is our proposal, and AWS does not define how to keep a ledger. The sample in this article has no ledger; it verifies only the classification of responses and the content of resend batches.

Why not to change the quantity when resending

For a record whose outcome you do not know, whether you resend unchanged or resend after fixing the cause, we recommend keeping the quantity at its finalized value. For failures that AWS describes as leaving the whole request unprocessed, such as a record that fails the quantity-format checks, no quantity was accepted first, so the corrected value becomes the new finalized quantity. This is because, for products that support Concurrent Agreements, usage is deduplicated hourly per combination of license, customer, hour, and dimension, and if you resend to the same combination with a different quantity, the first quantity is billed. Records sent in separate requests are not summed either. (AWS's seller guide) On the other hand, identical requests are idempotent, and you can retry with the same records or a subset of them. (AWS's API reference)

An implementation that re-aggregates usage just before resending does not fit these two properties. For example, suppose you finalize the quantity for the 03:00 hour as 2 at 04:10 and send it, but receive no response. At 04:20, usage for the 03:00 hour equivalent to a quantity of 3 arrives late, and re-aggregating makes the quantity to send 5. If AWS processed the first request, the record of 5 becomes DuplicateRecord, and 2 is billed. The side that received no response cannot tell whether it was processed. If you still write 5 to the submission ledger, then in the case where the request was processed, the 2 AWS uses for billing and the 5 in your ledger remain inconsistent.

Finalize the quantity for each hour only once, and when resending, send the finalized value from the submission ledger as is. Record usage that arrives after finalization separately instead of adding it to the finalized row, and decide in advance whether to leave it unbilled and absorb it yourself or to consult AWS Marketplace Seller Operations about how to handle it. Resending the finalized value as is and recording late usage separately are both our proposals. Why late usage remains unbilled is explained in the article on metering implementation.

DuplicateRecord: find the quantity sent earlier and where it came from

DuplicateRecord is a record that was not accepted. It is returned when a record for the same customer, dimension, and time was sent earlier and only the quantity differs. (AWS's API reference) Billing is based on the quantity sent earlier, so fixing and resending this record does not change billing. AWS compares quantities by value in its duplicate check and treats 17, 17.0, and 17.00 as the same quantity. A difference in notation is therefore not the cause, so compare the difference from the quantity sent earlier by value. (AWS's seller guide) What you should investigate is where the earlier record came from.

  • Submission ledger: whether the row for the same license, customer, hour, and dimension has a sent record and a MeteringRecordId. If so, record the difference between that quantity and this quantity
  • AWS CloudTrail: whether there are submissions not in the submission ledger. You can use AWS CloudTrail to check records you sent (AWS's seller guide)
  • Sending process: whether two jobs or workers are sending the same hour, and whether quantities are re-aggregated on every retry
  • Timestamp: whether different times within the same hour, such as 03:00 and 03:27, are used. Deduplication is hourly, so even if you intended them as separate records, they are treated as the same combination (AWS's seller guide)

If you are in the middle of migrating from the ProductCode method to the LicenseArn method, suspect the other path as well. Sending the same hour for the same customer with both methods results in double billing. (AWS's API reference) During migration, requests from both methods work at the same time, and the once-per-hour limit is applied separately for each method. (AWS Marketplace blog) Even if no DuplicateRecord appears, check with the submission ledger and AWS CloudTrail that you are not sending the same hour with both methods.

AWS's seller guide and AWS's API reference describe the unit of deduplication differently. Configuring metering for usage in the seller guide says that, for products that support Concurrent Agreements, deduplication uses the combination of license, customer, hour, and dimension. UsageRecordResult in the API reference describes DuplicateRecord as a record with the same customer, dimension, and time but a different quantity, and does not include the license. If the check follows UsageRecordResult's description, sending records for the same hour and the same dimension under two licenses of the same buyer may cause one of them to become DuplicateRecord. We recommend including LicenseArn in the submission ledger's unique key. If one of the two licenses' records still becomes DuplicateRecord, ask AWS Marketplace Seller Operations which unit the check used. AWS Marketplace Seller Operations is AWS Marketplace's support team for sellers, and you can contact it from the support page in the AWS Partner Central console (AWS Partner Central and Marketplace Support). (AWS's Getting support page)

CustomerNotSubscribed: check the license state and events

CustomerNotSubscribed is also a record that was not accepted. The cause is one of the following: the identifier is invalid, the identifier has no active agreement for the product, or the buyer's AWS account is suspended. If there is no active agreement, subsequent records for that buyer also keep failing until the buyer subscribes to the product. (AWS's API reference)

This AWS API reference describes all three causes as states of the buyer's identifier (CustomerIdentifier). For records sent with the LicenseArn method, you can't tell from that description which state of which license produces this result, so ask AWS Marketplace Seller Operations. Until you get an answer, we recommend the following two measures.

  • Stop sending only to the LicenseArn that produced this result, and keep sending to the same buyer's other active licenses. For products that support Concurrent Agreements, metering works per license, and even if one agreement is canceled, you can keep sending to the remaining agreements (AWS's seller guide)
  • Keep records that returned CustomerNotSubscribed in the submission ledger as candidates for missed billing, and do not resend them automatically

For the licenses you stopped, go back through the events received through Amazon EventBridge.

  • License Updated (an event that notifies you that the buyer's entitlements changed): whether you sent records before receiving it. When License Updated is received, the buyer's account is ready to accept metering, and records sent before that are not counted (AWS's seller guide)
  • License Deprovisioned (an event that notifies you that the buyer's entitlements ended) and Purchase Agreement Ended (an event that notifies you that an agreement expired, was canceled, or ended): whether you received them. The grace period for sending the final usage after an agreement ends is 1 hour (AWS's seller guide)
  • Purchase Agreement Advisory Issued (an event that notifies you that AWS detected an issue that could invalidate the agreement): whether you received it. Conditions listed include closure, compromise, or fraudulent use of the buyer's account (AWS's seller guide)

Will records sent before License Updated be accepted if you resend the same hour after receiving it? Onboarding buyers to your SaaS product in the seller guide says such records are not counted, but leaves open which result those records return and whether resending them will be accepted. With a product in Limited visibility, you can check both results by sending one record for the same hour before and one after receiving License Updated.

Time constraints: submission deadlines and usage start

TimestampOutOfBoundsException is returned when a record's time is outside the accepted range. Records 24 hours or more after the usage occurred are not accepted, and the previous month's usage is not accepted after 06:00 UTC on the 1st of the following month, even within 24 hours. The Timestamp also cannot be before the start of software usage. (BatchMeterUsage and UsageRecord in AWS's API reference)

The troublesome part is that if even one record is out of range, the entire batch is not processed. In a batch that returned the exception, the in-range records also remain unprocessed. Remove the out-of-range records and resend the rest unchanged. (AWS's API reference) If you resend with the out-of-range records still included, the entire batch keeps stopping with the same exception. Identify which records are out of range by calculating each record's deadline yourself, just before sending and right after receiving the exception.

Applying the two deadlines in AWS's API reference to each record, the deadline you calculate is the earlier of "24 hours after the Timestamp" and "06:00 UTC on the 1st of the month after the Timestamp." (AWS's API reference) For a record in the 23:00 hour on November 30, the deadline is 06:00 UTC on December 1, not 23:00 on December 1, 24 hours later. If your calculation finds no expired records, investigate clock skew on the sending side or errors in the value put in Timestamp.

Records past the deadline are not accepted even if resent. (AWS's API reference) We recommend keeping them in the submission ledger as expired and treating them as usage that could not be billed. If you do not send every hour, record delays grow larger when an incident occurs. (AWS's seller guide) To find stopped or backed-up submission jobs early, decide how old unsent records can get before you send an alert. How to set that threshold is covered in the article on metering implementation.

If an agreement starts partway through an hour, set the Timestamp to the start time or later. UsageRecord in the API reference asks that the Timestamp not be before the start of usage, but leaves open whether TimestampOutOfBoundsException or InvalidLicenseException is returned when you send a time before the start of usage. With a product in Limited visibility, sending one record with a time just before the start of usage lets you check which exception is returned.

AWS's API reference describes the handling of a record exactly 24 hours after usage differently in BatchMeterUsage and UsageRecord. BatchMeterUsage says "records 24 hours or more old are not accepted," and UsageRecord says "you can send up to 24 hours back." Under the former, a record exactly 24 hours old is not accepted; under the latter, it can be sent. The two pages therefore leave open how the boundary is handled. Neither settles how records with a future time are handled. We recommend an operation that sends neither records exactly 24 hours old nor records with a future time. That way, boundary records whose handling is unsettled are kept out of the submissions used for billing. If you want to confirm boundary handling, send one record exactly 24 hours after usage and one with a future time to a product in Limited visibility, and record the results. The sample introduced later treats a record exactly 24 hours old as expired and does not send records with a future time.

When an agreement ends, a separate limit applies besides the 24-hour limit: a 1-hour grace period for final submission. The event that starts this grace period is described differently in several pages of AWS's seller guide and in the migration guide published on the AWS Marketplace blog. The Amazon EventBridge page in the seller guide sets the grace period as 1 hour from receipt of License Deprovisioned, after which BatchMeterUsage does not accept usage. The migration guide on the AWS Marketplace blog names two different events in a single post: it calls Purchase Agreement Ended the event that grants the 1-hour grace period, and License Deprovisioned the event that marks the start of the grace period. Configuring metering for usage in the seller guide says, for SaaS Subscription products, that it is 1 hour from the unsubscribe-pending notification that arrives when the buyer starts unsubscribing. SaaS Subscription pricing in the seller guide counts 1 hour from Purchase Agreement Ended and says you receive License Deprovisioned after that hour. The SaaS Contract pricing page in the seller guide counts 1 hour from the entitlement-updated notification (a notification that the entitlements changed) that arrives when an agreement expires. You can't tell from these descriptions which notification's receipt time to use as the starting point. So that you are on time whichever one is the starting point, we recommend finishing final submission, for that agreement, within 1 hour of the earliest end-of-agreement notification you received. For products that receive notifications through Amazon EventBridge, the start time is whichever of Purchase Agreement Ended and License Deprovisioned you received first; for products that also receive the unsubscribe-pending notification, it is the earliest of all of them, including that one. A notification that also arrives for contract changes, such as License Updated, does not count as the starting point just because you received it. For SaaS Contract and SaaS Contract with Consumption, count from its receipt time only when an entitlement check (GetEntitlements), filtered by that agreement’s LicenseArn and read until there is no NextToken, shows that the agreement has ended (GetEntitlements in AWS's API reference). SaaS Subscription does not use entitlement checks, so this notification is not included as the starting point. For the official starting point, ask AWS Marketplace Seller Operations which notification's receipt time to count from. In particular, confirm whether a notification showing that an entitlement has expired counts. The design, including how to stop usage after the end, is covered in the article on metering implementation.

License mix-ups: when they cause errors and when they do not

With Concurrent Agreements, one AWS account can hold multiple agreements for the same product. For example, the sales planning department and the R&D department each buy a separate agreement from a shared procurement AWS account and use separate tenants in the SaaS. CustomerAWSAccountId is the buyer's AWS account ID, so it has the same value for both agreements. What differs per agreement is LicenseArn, which uniquely identifies each individual license granted. (AWS's API reference, AWS Marketplace blog) The differences between identifiers are laid out in What are AWS Marketplace Concurrent Agreements?, and mapping to tenants in How do you map AWS Marketplace agreements to SaaS tenants?.

To avoid InvalidLicenseException, the LicenseArn must be valid, match the customer, and the usage must be within the license's validity period. (AWS's API reference) Whether a mix-up causes this exception depends on what it was mixed up with.

  • Another buyer's LicenseArn, an invalid LicenseArn, or usage outside the validity period: each violates one of the three requirements, so under the API reference's description they are subject to InvalidLicenseException. Whether this exception or CustomerNotSubscribed is actually returned, for example with a LicenseArn after the agreement ended, needs to be confirmed with a product in Limited visibility
  • The LicenseArn of another active agreement in the same AWS account: can meet all three requirements
  • Using CustomerIdentifier with a LicenseArn-method product: not supported for new integrations (AWS's API reference)

A mix-up in which the sales planning department's usage lands on the R&D department's agreement is the case of using the LicenseArn of another active agreement in the same AWS account. You can't tell from this AWS API reference whether such a record is rejected with InvalidLicenseException. If you can buy a product in Limited visibility under two agreements from the same account, you can send one record of one tenant's usage with the other's LicenseArn and check whether it is accepted and which agreement's billing it appears on. In case it is accepted, we recommend looking up the LicenseArn assigned to the tenant in the license ledger before sending, checking it against that license's buyer AWS account ID and usage start date, and stopping it if they do not match. An implementation that looks up "that account's license" by AWS account ID alone works correctly while there is only one agreement, and goes wrong from the day a second agreement is made.

InvalidLicenseException is returned as a failure of the entire API call. AWS's API reference explains that for TimestampOutOfBoundsException the entire batch is not processed, but leaves open whether the remaining records were processed in a batch that returned InvalidLicenseException. AWS says identical requests are idempotent and can be retried with the same records or a subset of them. Resending the remaining records does not bill records that were already processed twice. (AWS's API reference) When it is returned, apply the same checks as before sending to each record in the batch and identify the records that violate the requirements. Keep only those records as under investigation and resend the rest with their finalized quantities. If you cannot identify them, we recommend sending the records one at a time to find the one that returns an exception. If the deadline passes while you wait, the correct records can no longer be billed either.

Store the CustomerAWSAccountId and LicenseArn used for these checks from the response of ResolveCustomer (the API that retrieves buyer information from the registration token passed when the buyer arrives at the registration page). (AWS's seller guide) If you need a mapping table between CustomerIdentifier and CustomerAWSAccountId for migrating from the ProductCode method, ask AWS Marketplace Seller Operations. (AWS's API reference) Do not use an AWS account ID you asked the buyer for directly, because its authenticity cannot be verified. (AWS's API reference)

Cases that fail before the fix, and results after the fix

You can try the decisions so far with a sample that runs on Node.js built-ins only. The sample consists of synthetic fixtures that imitate BatchMeterUsage responses, a corrected version that performs pre-submission checks and classifies responses, a naive implementation for comparison, and tests. It does not use a connection to AWS, the AWS SDK, AWS credentials, or external npm packages.

Even if the sample classifies a record as "accepted," that does not mean AWS accepted or billed it. The fixture responses were built using the shapes, Status values, and exceptions shown in AWS's API reference (BatchMeterUsage, UsageRecordResult), and nothing was sent to AWS. Whether AWS accepts the records needs to be confirmed separately with a product in Limited visibility.

Save the fixtures, corrected version, naive implementation, tests, and comparison table output to the same directory (comments, test names, and output labels in these files are in Japanese), then run the following commands.

node --test metering.test.mjs
METERING_IMPL=naive node --test metering.test.mjs
node report.mjs

The first line runs the corrected version, and the second runs the same tests with the naive implementation swapped in. On Node.js v24.18.1, the corrected version passes all 19 tests, and the naive implementation fails 18 of 19. The only case the naive implementation passes is the one in which every record is Success. Tests of the normal path alone detect none of the errors described so far.

To check whether your own implementation has the same errors, compare the naive implementation's errors with the tests they fail. The test names below are English renderings of the Japanese names in the test file.

Error in the naive implementationFailing testsExpected result of the corrected version
Marks all records accepted on HTTP 200"Even on HTTP 200, classify Status and unprocessed records per record," "Resend only unprocessed records, with the finalized quantity," "Resend records missing from the response, with the finalized quantity and the same content," "Even on Success, if the quantity in the response differs from the quantity sent, do not mark it accepted; investigate," and "Even if the response returns the quantity in the QuantityAsDecimal notation, mark it accepted if the value is the same" (5 tests)Marks only Success as "Accepted"; classifies DuplicateRecord and CustomerNotSubscribed as "Do not resend; investigate," UnprocessedRecords and records missing from the response as "Resend unchanged," and a Success with a different quantity as "Do not resend; investigate"
Re-aggregates the quantity on every resend"On ThrottlingException, resend all records unchanged," "On InternalServiceErrorException, resend all records unchanged," "On InternalFailure (common error), resend all records unchanged," "On ServiceUnavailable (common error), resend all records unchanged," "On RequestTimeoutException (common error), resend all records unchanged," and "On no response (timeout), resend all records unchanged" (6 tests)Even if usage with a quantity of 3 arrives after finalization, the quantity resent stays 2
Looks up the license by AWS account ID alone"Two licenses in the same AWS account are sent with a separate LicenseArn per tenant" (1 test)The R&D department tenant's usage is sent with the R&D department's LicenseArn
Puts the send time in Timestamp"Timestamp is the start of the hour in which usage occurred, not the send time" (1 test)The Timestamp for usage in the 03:00 hour is 03:00
Resends all records on any API call error without checking its type"On TimestampOutOfBoundsException, remove expired records and resend the rest," "On InvalidLicenseException, do not resend automatically," and "On ValidationError, do not resend automatically" (3 tests)Does not send expired records (the sample classifies them as "Do not resend; investigate"; in the ledger they become expired) and resends the in-range records in a new batch. In the sample, classifies all records of an InvalidLicenseException and a ValidationError as "Do not resend; investigate"
Does not check submission deadlines"Submission deadline: 24 hours, and 06:00 UTC on the 1st of the following month at month end" (1 test)Does not send records past the earlier of 24 hours after usage or 06:00 UTC on the 1st of the following month
Performs no pre-submission checks"Pre-submission checks stop license mix-ups and ProductCode-method fields" (1 test)Detects tenant-to-LicenseArn mismatches, usage before start, expired records, non-integer quantities, and ProductCode and CustomerIdentifier

Besides the items this test checks, the corrected version's pre-submission checks also detect a LicenseArn that is not in the license ledger, a mismatch between the LicenseArn and the buyer's AWS account ID, a time that is not on the hour, and more than 25 records in one request. The sample has no tests for these four, so add them to your own tests. The sample's check uses a single value, the start time of the row's hour, to verify both that the time is on the hour and that it is not before the start of use. A row for the first hour of an agreement that starts partway through an hour is stopped either way: as before the start of use (before_license_start) if the time is on the hour, and as a time that is not on the hour (not_hour_aligned) if it is the start time or later. In your own implementation, keep the start time of the hour and the record's Timestamp as separate values, and check that the time is on the hour against the start time of the hour, and that it is not before the start of use against the Timestamp. The quantity check is based on Quantity being an integer from 0 to 2147483647, and it stops non-integer quantities before sending. (AWS's API reference) For fractional usage such as a number of GB, AWS's API reference has you send QuantityAsDecimal instead of Quantity. Quantity is deprecated, and you cannot specify both in the same record. (AWS's API reference) The sample sends records with Quantity and does not include checks of the QuantityAsDecimal format (up to six decimal places). If your product sends fractions, add checks of that format to your own tests. Only the comparison of the quantity in the response is done by value, whichever of Quantity and QuantityAsDecimal it comes back in. The sample also separates the common errors in the diagnostic table. It resends InternalFailure, ServiceUnavailable, and RequestTimeoutException unchanged. For whole-API-call failures such as InvalidLicenseException and ValidationError, the sample does not identify the offending record and treats every record as not resent automatically. Any exception not in the diagnostic table is not separated and is treated as not resent automatically (unknown_error). In your implementation, stop only the offending record and resend the rest, as the diagnostic table and the ledger table show.

The core of the corrected version is the processing that splits an HTTP 200 response per record. The comments in this excerpt are English translations of the Japanese comments in the downloadable file; "AWS specification" marks behavior defined by AWS's API reference, and "our proposal" marks handling we recommend.

  if (outcome.httpStatus === 200) {
    // HTTP 200 only shows that the call succeeded. Per-record results are in Results and UnprocessedRecords (AWS specification)
    const results = new Map(outcome.body.Results.map((result) => [recordKey(result.UsageRecord), result]));
    const unprocessed = new Set(outcome.body.UnprocessedRecords.map(recordKey));
    return records.map((record) => {
      const key = recordKey(record);
      // AWS specification: UnprocessedRecords were not processed because of a service-side error and can be retried
      if (unprocessed.has(key)) return decide(record, ACTION.RESEND_SAME, 'unprocessed');
      const result = results.get(key);
      // A record missing from the response has an unknown result. Identical requests are idempotent, so resend it unchanged (our proposal)
      if (!result) return decide(record, ACTION.RESEND_SAME, 'missing_from_response');
      switch (result.Status) {
        case 'Success':
          if (!sameQuantity(result.UsageRecord, record)) {
            return decide(record, ACTION.DO_NOT_RESEND, 'quantity_mismatch_in_result');
          }
          return decide(record, ACTION.ACCEPTED, 'success', {meteringRecordId: result.MeteringRecordId});
        case 'DuplicateRecord':
          // AWS specification: an earlier record exists for the same customer, dimension, and time with a different quantity. Resending with a changed quantity cannot correct it
          return decide(record, ACTION.DO_NOT_RESEND, 'duplicate_record');
        case 'CustomerNotSubscribed':
          // AWS specification: the identifier is invalid, there is no active agreement, or the account is suspended
          return decide(record, ACTION.DO_NOT_RESEND, 'customer_not_subscribed');
        default:
          return decide(record, ACTION.DO_NOT_RESEND, 'unknown_status');
      }
    });
  }

Even for Success, if the quantity in the response record differs in value from the quantity sent, the record is classified as "Do not resend; investigate" with the reason quantity_mismatch_in_result. sameQuantity compares by value, whichever of Quantity and QuantityAsDecimal the response uses. If your own code mismatches sent records with response records, this branch finds it.

Running node report.mjs lists the classifications of the corrected version and the naive implementation for each fixture. The fixtures have four tenants: alpha and beta are two agreements in a shared procurement AWS account (the sales planning and R&D departments), and gamma and delta are separate buyers. The heading mixed is a fixture with an HTTP 200 response in which alpha is Success, beta is DuplicateRecord, gamma is CustomerNotSubscribed, and delta is in UnprocessedRecords. In the output, 修正版 is the corrected version, 素朴 is the naive implementation, 再送バッチ is the resend batch, and なし means none. The resend batch column lists license and quantity pairs; DELTA:2 means sending a quantity of 2 to delta's license.

# mixed(HTTP 200)
  alpha         修正版=ACCEPTED(success)  素朴=ACCEPTED
  beta          修正版=DO_NOT_RESEND(duplicate_record)  素朴=ACCEPTED
  gamma         修正版=DO_NOT_RESEND(customer_not_subscribed)  素朴=ACCEPTED
  delta         修正版=RESEND_SAME(unprocessed)  素朴=ACCEPTED
  再送バッチ 修正版=[DELTA:2]  素朴=[なし]
# ThrottlingException
  alpha         修正版=RESEND_SAME(throttled)  素朴=RESEND_SAME
  beta          修正版=RESEND_SAME(throttled)  素朴=RESEND_SAME
  gamma         修正版=RESEND_SAME(throttled)  素朴=RESEND_SAME
  delta         修正版=RESEND_SAME(throttled)  素朴=RESEND_SAME
  再送バッチ 修正版=[ALPHA:10, BETA:4, GAMMA:7, DELTA:2]  素朴=[ALPHA:10, BETA:4, GAMMA:7, DELTA:5]

Applying the mixed result to the ledger as the section on recording diagnoses describes, alpha is sent, beta and gamma are under investigation, and delta stays pending with attempts at 1. Only delta's quantity of 2 is resent, and even if usage with a quantity of 3 arrives late, the quantity sent stays 2. Resending does not fix why beta's and gamma's usage is missing from billing. For beta, investigate the difference from the quantity sent earlier; for gamma, investigate the license state and the event history. The naive implementation marks all four records accepted on HTTP 200, so in the ledger all four look sent, and neither delta's resend nor the investigation of beta and gamma begins.

In the ThrottlingException case, both the corrected version and the naive implementation mark all records for resending. Looking only at the classifications, both seem correct. In the resend batch, however, the naive implementation adds the quantity of 3 that arrived after finalization to delta and tries to send 5. Tests that check only the classification results miss this error. Check that the content of the batch you resend matches the first submission as well.

What to confirm with a product in Limited visibility

The sample can confirm only that your own code follows decisions based on the specification. For the following AWS-side behavior, buy a product whose visibility is set to Limited from your own account or an account added to the allowlist, or confirm with AWS Marketplace Seller Operations. Test purchase steps are in SaaS Subscription integration in AWS's seller guide and in the AWS Marketplace blog's introduction to the metering agent skill. For how the Testing and integrations step in AWS Partner Central verifies the records of usage submissions, see our article What Does “Testing and integrations” in AWS Partner Central Verify?.

  • The Status and MeteringRecordId returned the second time when you send an identical record twice
  • Whether both become Success when you send records for the same hour and the same dimension under two licenses of the same buyer
  • The result returned for a record sent before receiving License Updated, and the result when you resend the same hour after receiving it
  • For a LicenseArn-method product, whether CustomerNotSubscribed or InvalidLicenseException is returned after an agreement ends or for an invalid LicenseArn
  • Whether a record sent with the LicenseArn of another agreement in the same AWS account is accepted (and, if accepted, whether it appears on that agreement's billing)
  • The error returned when you send CustomerIdentifier for a LicenseArn-method product
  • Whether the remaining records in a batch that returned InvalidLicenseException are processed
  • The results returned for a Timestamp before the start of usage, exactly 24 hours ago, and in the future
  • The exception returned when you send a quantity that breaks the format (such as a quantity with seven or more decimal places), and how the other records in the same batch are handled
  • Whether the response UsageRecord returns the quantity in Quantity or QuantityAsDecimal
  • In what form a fractional quantity sent in QuantityAsDecimal appears in billing
  • The result returned for a record past the final submission grace period

Metering records sent after purchase are included in the buyer's AWS bill. (AWS's seller guide) Decide the quantities to send in testing and who records the results before you run the tests. If the results differ from the sample's classifications, fix both the fixtures and the classification.

For the whole set of tests to run yourself before launch, see “Tests before launch” in the metering implementation article, which divides them into quantity finalization, retries, LicenseArn, the delivery deadline and month-end boundary, and contract start and end. When you add rows of the diagnostic table to your own regression tests, use the AWS Marketplace SaaS integration regression test matrix. R11 (resending records whose submission result is unknown), R12 (resending UnprocessedRecords), R13 (investigating DuplicateRecord), and R14 (month-end submission deadline) in the regression test matrix correspond to rows of this article's diagnostic table. A setup that runs the tests on every CI run is explained in Running AWS Marketplace integration tests in CI, including isolated initial data and clock handling.

When building a new metering integration, also check AWS's official aws-marketplace-metering. This agent skill targets SaaS Subscription products, can validate the integration flow with a dry run that does not call BatchMeterUsage, and generates code structured to keep submission results per record. (AWS Marketplace blog) When you read the generated code, check how it handles each row of the diagnostic table as well.

Deshima is a service provided by us at Anti-Pattern Inc. that supports listing SaaS on AWS Marketplace. As of November 11, 2026, in addition to SaaS Contract (a pricing model that defines the contract term and purchased entitlements in advance and bills upfront or on a payment schedule), it reports usage for usage-based pricing: SaaS Subscription and the usage portion of SaaS Contract with Consumption. For usage-based products, your SaaS registers the final usage quantity for each hour through the Deshima API, and Deshima reports it to AWS Marketplace with BatchMeterUsage. As of November 15, 2026, the Deshima API accepts whole-number quantities only, and Deshima sends them with the Quantity field of BatchMeterUsage. If you bill in fractional units, we recommend defining the dimension’s unit at a granularity you can count in whole numbers and registering whole numbers. Deshima retries failed submissions, and you can check the submission status in the Deshima console. Measuring usage and aggregating it per hour stays in your SaaS. Usage that AWS has accepted cannot be cancelled or corrected when it is sent through Deshima either, so register a quantity only after it is final. For listing products with requirements outside Deshima's scope, such as Channel Partner Private Offers (CPPO), we propose implementation approaches for those requirements as part of our listing design support, one of our professional services (page in Japanese). Deshima is updated frequently, so to see the latest features and scope, create a free account (currently in Japanese) and check the documentation in the product.

Frequently asked questions

If BatchMeterUsage returns HTTP 200, was the usage accepted?
HTTP 200 only shows that the API call succeeded. Check each record's result with the Status in Results in the response. Besides Success, Status can be DuplicateRecord or CustomerNotSubscribed, which indicate that the record was not accepted. Records in UnprocessedRecords in the response were not processed, so resend them with the same content.
Can I correct a record that returned DuplicateRecord by fixing the quantity and resending?
No. DuplicateRecord indicates that a record with a different quantity for the same customer, dimension, and time was sent earlier. According to AWS's seller guide (Configuring metering for usage), if you resend with a different quantity, the first quantity is billed. Do not resend; investigate the quantity sent earlier and its source using your own submission ledger and AWS CloudTrail records.
If I send usage with the LicenseArn of a different agreement in the same AWS account, will it return an error?
In AWS's API reference (BatchMeterUsage), the requirements for avoiding InvalidLicenseException are three: the LicenseArn is valid, it matches the customer, and the usage is within the license's validity period. The LicenseArn of another active agreement in the same AWS account can meet all three requirements. Check the tenant-to-LicenseArn mapping against your own license ledger and stop the record before sending. Whether the API rejects this record should be confirmed with a product in Limited visibility.
How do I reflect BatchMeterUsage results in the submission ledger?
For a result in which you cannot tell whether the record was processed, do not update the finalized quantity in the ledger. Mark a Success whose response quantity matches the quantity you sent as sent, and store the MeteringRecordId. For UnprocessedRecords, ThrottlingException, InternalServiceErrorException, the temporary common errors (such as InternalFailure), and no response, keep the row pending, increase the attempt count, and resend with the same quantity. Treat DuplicateRecord, CustomerNotSubscribed, and the offending record of an InvalidLicenseException as rows that are not resent automatically and are investigated, and resend the rest of the batch with the finalized quantities. This is the ledger handling that we at Anti-Pattern Inc. recommend, based on AWS's specifications.