> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/api-reference/software-delivery-agent-apis/infrastructure-as-code-management/flexi-billing.md).

# Flexi Billing

Flexi Billing Service exposes internal, service-to-service-only operations for the flexi billing V3 pipeline: sanity reads of the ledger-reconstructed billable units, the flexi\_billing\_events\_daily\_runs rows, and the billable Ansible hosts for a day, plus replaying discovery, delivery, or Ansible host billing for a day.

## Sanity read of the Ansible hosts billed for a day

> Returns the hosts Ansible host billing sends as IACM\_ACTIVE\_HOSTS for the given date: one row per host active in ansible\_usage over the 30 days ending on it, with the deterministic id its event carries. Optionally scoped to a single account. The date must be a completed UTC day (before today). total\_count is the full host count for the day regardless of limit.

```json
{"openapi":"3.0.3","info":{"title":"Infrastructure as Code Management","version":"0.1.0"},"tags":[{"name":"flexi_billing","description":"Flexi Billing Service exposes internal, service-to-service-only operations for the flexi billing V3 pipeline: sanity reads of the ledger-reconstructed billable units, the flexi_billing_events_daily_runs rows, and the billable Ansible hosts for a day, plus replaying discovery, delivery, or Ansible host billing for a day."}],"servers":[{"url":"http://localhost:80"}],"paths":{"/api/flexi-billing/ansible-host-ledger":{"get":{"tags":["flexi_billing"],"summary":"Sanity read of the Ansible hosts billed for a day","description":"Returns the hosts Ansible host billing sends as IACM_ACTIVE_HOSTS for the given date: one row per host active in ansible_usage over the 30 days ending on it, with the deterministic id its event carries. Optionally scoped to a single account. The date must be a completed UTC day (before today). total_count is the full host count for the day regardless of limit.","operationId":"flexi_billing#get-ansible-host-ledger","parameters":[{"name":"date","in":"query","description":"UTC calendar day to act on, in YYYY-MM-DD format; resolved to 00:00 UTC of that date. Must be a completed UTC day (before today).","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"UTC calendar day to act on, in YYYY-MM-DD format; resolved to 00:00 UTC of that date. Must be a completed UTC day (before today)."}},{"name":"account","in":"query","description":"Optional account identifier; empty means all accounts.","allowEmptyValue":true,"schema":{"type":"string","description":"Optional account identifier; empty means all accounts.","maxLength":128}},{"name":"limit","in":"query","description":"Optional maximum number of rows to return; absent or <= 0 returns all rows for the day. total_count is always the full count, independent of limit.","allowEmptyValue":true,"schema":{"type":"integer","description":"Optional maximum number of rows to return; absent or <= 0 returns all rows for the day. total_count is always the full count, independent of limit.","format":"int64","minimum":0}}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FlexiBillingAnsibleHostLedgerResponse"}}}},"400":{"description":"BadRequestError: Bad Request response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"UnauthorizedError: Unauthorized response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"ForbiddenError: Forbidden response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"NotFoundError: Not Found response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"408":{"description":"TimeoutError: Request Timeout response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"ConflictError: Conflict response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"423":{"description":"LockedError: Locked response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"499":{"description":"ContextCancelledError:  response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"InternalServerError: Internal Server Error response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"BadGatewayError: Bad Gateway response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"schemas":{"FlexiBillingAnsibleHostLedgerResponse":{"type":"object","properties":{"account":{"type":"string","description":"Account the read targeted; empty means all accounts"},"count":{"type":"integer","description":"Number of rows returned (after any limit)","format":"int64"},"date":{"type":"string","description":"Requested day"},"epoch_day":{"type":"integer","description":"Resolved 00:00 UTC Unix seconds for the date","format":"int64"},"rows":{"type":"array","items":{"$ref":"#/components/schemas/FlexiBillingAnsibleHost"}},"total_count":{"type":"integer","description":"Full number of billable hosts for the day (and account), independent of limit","format":"int64"}},"description":"Ansible hosts billed from ansible_usage for a day","required":["date","epoch_day","count","total_count","rows"]},"FlexiBillingAnsibleHost":{"type":"object","properties":{"account":{"type":"string"},"host_address":{"type":"string"},"id":{"type":"string","description":"Deterministic billing event id (the event's idempotency key)"},"last_activity":{"type":"integer","description":"Last run of the host, in epoch milliseconds, as sent in the event's last_activity tag","format":"int64"},"org":{"type":"string","description":"Org of the host's latest scoped usage in the window"},"parent_unique_id":{"type":"string","description":"Empty for hosts last used before scope was recorded"},"project":{"type":"string","description":"Project of the host's latest scoped usage in the window"}},"description":"A host billed as IACM_ACTIVE_HOSTS for a day, from ansible_usage","required":["id","account","host_address","org","project","parent_unique_id","last_activity"]},"Error":{"type":"object","properties":{"fault":{"type":"boolean","description":"Is the error a server-side fault?"},"id":{"type":"string","description":"ID is a unique identifier for this particular occurrence of the problem."},"message":{"type":"string","description":"Message is a human-readable explanation specific to this occurrence of the problem."},"name":{"type":"string","description":"Name is the name of this class of errors."},"temporary":{"type":"boolean","description":"Is the error temporary?"},"timeout":{"type":"boolean","description":"Is the error a timeout?"}},"required":["name","id","message","temporary","timeout","fault"]}}}}
```

## Replay Ansible host billing for a day

> Enqueues IACM\_ACTIVE\_HOSTS billing for one account, or the Ansible host scheduler fan-out for all accounts, re-sending one Kafka event per host active in ansible\_usage over the 30 days ending on the given date. The date must be a completed UTC day (before today). Idempotent: events carry deterministic idempotency keys, so UDP deduplicates hosts already delivered.

```json
{"openapi":"3.0.3","info":{"title":"Infrastructure as Code Management","version":"0.1.0"},"tags":[{"name":"flexi_billing","description":"Flexi Billing Service exposes internal, service-to-service-only operations for the flexi billing V3 pipeline: sanity reads of the ledger-reconstructed billable units, the flexi_billing_events_daily_runs rows, and the billable Ansible hosts for a day, plus replaying discovery, delivery, or Ansible host billing for a day."}],"servers":[{"url":"http://localhost:80"}],"paths":{"/api/flexi-billing/ansible-hosts":{"post":{"tags":["flexi_billing"],"summary":"Replay Ansible host billing for a day","description":"Enqueues IACM_ACTIVE_HOSTS billing for one account, or the Ansible host scheduler fan-out for all accounts, re-sending one Kafka event per host active in ansible_usage over the 30 days ending on the given date. The date must be a completed UTC day (before today). Idempotent: events carry deterministic idempotency keys, so UDP deduplicates hosts already delivered.","operationId":"flexi_billing#trigger-ansible-hosts","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TriggerFlexiBillingAnsibleHostsRequest"}}}},"responses":{"202":{"description":"Accepted response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FlexiBillingTriggerResponse"}}}},"400":{"description":"BadRequestError: Bad Request response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"UnauthorizedError: Unauthorized response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"ForbiddenError: Forbidden response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"NotFoundError: Not Found response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"408":{"description":"TimeoutError: Request Timeout response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"ConflictError: Conflict response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"423":{"description":"LockedError: Locked response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"499":{"description":"ContextCancelledError:  response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"InternalServerError: Internal Server Error response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"BadGatewayError: Bad Gateway response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"schemas":{"TriggerFlexiBillingAnsibleHostsRequest":{"type":"object","properties":{"account":{"type":"string","description":"Optional account identifier; empty means all accounts.","maxLength":128},"date":{"type":"string","description":"UTC calendar day to act on, in YYYY-MM-DD format; resolved to 00:00 UTC of that date. Must be a completed UTC day (before today)."},"force":{"type":"boolean","description":"When an identical job is already queued (e.g. waiting out a retry), make it run immediately instead of leaving it.","default":false}},"required":["date"]},"FlexiBillingTriggerResponse":{"type":"object","properties":{"account":{"type":"string","description":"Account the trigger targeted; empty means all accounts"},"date":{"type":"string","description":"Requested day"},"epoch_day":{"type":"integer","description":"Resolved 00:00 UTC Unix seconds for the date","format":"int64"},"job_id":{"type":"integer","description":"River job acted on","format":"int64"},"job_state":{"type":"string","description":"State of the River job after the trigger"},"message":{"type":"string","description":"Human-readable summary"},"outcome":{"type":"string","description":"What happened to the job","enum":["enqueued","already_queued","retried","running"]}},"description":"Result of a flexi billing trigger","required":["outcome","job_id","job_state","date","epoch_day","message"]},"Error":{"type":"object","properties":{"fault":{"type":"boolean","description":"Is the error a server-side fault?"},"id":{"type":"string","description":"ID is a unique identifier for this particular occurrence of the problem."},"message":{"type":"string","description":"Message is a human-readable explanation specific to this occurrence of the problem."},"name":{"type":"string","description":"Name is the name of this class of errors."},"temporary":{"type":"boolean","description":"Is the error temporary?"},"timeout":{"type":"boolean","description":"Is the error a timeout?"}},"required":["name","id","message","temporary","timeout","fault"]}}}}
```

## Sanity read of the billable units reconstructed from the ledger for a day

> Reconstructs the billable units from workspace\_history as of the end of the given date (UTC) and returns them (the rows discovery would write). Optionally scoped to a single account. total\_count is the full unit count for the day regardless of limit.

```json
{"openapi":"3.0.3","info":{"title":"Infrastructure as Code Management","version":"0.1.0"},"tags":[{"name":"flexi_billing","description":"Flexi Billing Service exposes internal, service-to-service-only operations for the flexi billing V3 pipeline: sanity reads of the ledger-reconstructed billable units, the flexi_billing_events_daily_runs rows, and the billable Ansible hosts for a day, plus replaying discovery, delivery, or Ansible host billing for a day."}],"servers":[{"url":"http://localhost:80"}],"paths":{"/api/flexi-billing/billing-ledger":{"get":{"tags":["flexi_billing"],"summary":"Sanity read of the billable units reconstructed from the ledger for a day","description":"Reconstructs the billable units from workspace_history as of the end of the given date (UTC) and returns them (the rows discovery would write). Optionally scoped to a single account. total_count is the full unit count for the day regardless of limit.","operationId":"flexi_billing#get-billing-ledger","parameters":[{"name":"date","in":"query","description":"UTC calendar day to act on, in YYYY-MM-DD format; resolved to 00:00 UTC of that date. Must be a completed UTC day (before today).","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"UTC calendar day to act on, in YYYY-MM-DD format; resolved to 00:00 UTC of that date. Must be a completed UTC day (before today)."}},{"name":"account","in":"query","description":"Optional account identifier; empty means all accounts.","allowEmptyValue":true,"schema":{"type":"string","description":"Optional account identifier; empty means all accounts.","maxLength":128}},{"name":"limit","in":"query","description":"Optional maximum number of rows to return; absent or <= 0 returns all rows for the day. total_count is always the full count, independent of limit.","allowEmptyValue":true,"schema":{"type":"integer","description":"Optional maximum number of rows to return; absent or <= 0 returns all rows for the day. total_count is always the full count, independent of limit.","format":"int64","minimum":0}}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FlexiBillingLedgerResponse"}}}},"400":{"description":"BadRequestError: Bad Request response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"UnauthorizedError: Unauthorized response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"ForbiddenError: Forbidden response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"NotFoundError: Not Found response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"408":{"description":"TimeoutError: Request Timeout response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"ConflictError: Conflict response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"423":{"description":"LockedError: Locked response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"499":{"description":"ContextCancelledError:  response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"InternalServerError: Internal Server Error response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"BadGatewayError: Bad Gateway response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"schemas":{"FlexiBillingLedgerResponse":{"type":"object","properties":{"account":{"type":"string","description":"Account the read targeted; empty means all accounts"},"count":{"type":"integer","description":"Number of rows returned (after any limit)","format":"int64"},"date":{"type":"string","description":"Requested day"},"epoch_day":{"type":"integer","description":"Resolved 00:00 UTC Unix seconds for the date","format":"int64"},"rows":{"type":"array","items":{"$ref":"#/components/schemas/FlexiBillingUnit"}},"total_count":{"type":"integer","description":"Full number of billable units for the day (and account), independent of limit","format":"int64"}},"description":"Billable units reconstructed from the ledger for a day","required":["date","epoch_day","count","total_count","rows"]},"FlexiBillingUnit":{"type":"object","properties":{"account":{"type":"string"},"id":{"type":"string","description":"Deterministic billing event id"},"org":{"type":"string"},"project":{"type":"string"},"provisioner":{"type":"string"},"provisioner_version":{"type":"string"},"terragrunt_provider":{"type":"boolean"},"unique_key":{"type":"string"},"workspace_id":{"type":"string"},"workspace_name":{"type":"string"}},"description":"A billable unit reconstructed from workspace_history for a day","required":["id","account","org","project","workspace_id","unique_key","provisioner","provisioner_version","workspace_name","terragrunt_provider"]},"Error":{"type":"object","properties":{"fault":{"type":"boolean","description":"Is the error a server-side fault?"},"id":{"type":"string","description":"ID is a unique identifier for this particular occurrence of the problem."},"message":{"type":"string","description":"Message is a human-readable explanation specific to this occurrence of the problem."},"name":{"type":"string","description":"Name is the name of this class of errors."},"temporary":{"type":"boolean","description":"Is the error temporary?"},"timeout":{"type":"boolean","description":"Is the error a timeout?"}},"required":["name","id","message","temporary","timeout","fault"]}}}}
```

## Sanity read of flexi\_billing\_events\_daily\_runs rows for a day

> Returns the flexi\_billing\_events\_daily\_runs rows for the given date (epoch\_day), optionally scoped to a single account. A day with no rows returns total\_count 0 and an empty list. total\_count is the full row count for the day regardless of limit.

```json
{"openapi":"3.0.3","info":{"title":"Infrastructure as Code Management","version":"0.1.0"},"tags":[{"name":"flexi_billing","description":"Flexi Billing Service exposes internal, service-to-service-only operations for the flexi billing V3 pipeline: sanity reads of the ledger-reconstructed billable units, the flexi_billing_events_daily_runs rows, and the billable Ansible hosts for a day, plus replaying discovery, delivery, or Ansible host billing for a day."}],"servers":[{"url":"http://localhost:80"}],"paths":{"/api/flexi-billing/daily-runs":{"get":{"tags":["flexi_billing"],"summary":"Sanity read of flexi_billing_events_daily_runs rows for a day","description":"Returns the flexi_billing_events_daily_runs rows for the given date (epoch_day), optionally scoped to a single account. A day with no rows returns total_count 0 and an empty list. total_count is the full row count for the day regardless of limit.","operationId":"flexi_billing#get-daily-runs","parameters":[{"name":"date","in":"query","description":"UTC calendar day to act on, in YYYY-MM-DD format; resolved to 00:00 UTC of that date. Must be a completed UTC day (before today).","allowEmptyValue":true,"required":true,"schema":{"type":"string","description":"UTC calendar day to act on, in YYYY-MM-DD format; resolved to 00:00 UTC of that date. Must be a completed UTC day (before today)."}},{"name":"account","in":"query","description":"Optional account identifier; empty means all accounts.","allowEmptyValue":true,"schema":{"type":"string","description":"Optional account identifier; empty means all accounts.","maxLength":128}},{"name":"limit","in":"query","description":"Optional maximum number of rows to return; absent or <= 0 returns all rows for the day. total_count is always the full count, independent of limit.","allowEmptyValue":true,"schema":{"type":"integer","description":"Optional maximum number of rows to return; absent or <= 0 returns all rows for the day. total_count is always the full count, independent of limit.","format":"int64","minimum":0}}],"responses":{"200":{"description":"OK response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FlexiBillingDailyRunsResponse"}}}},"400":{"description":"BadRequestError: Bad Request response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"UnauthorizedError: Unauthorized response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"ForbiddenError: Forbidden response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"NotFoundError: Not Found response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"408":{"description":"TimeoutError: Request Timeout response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"ConflictError: Conflict response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"423":{"description":"LockedError: Locked response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"499":{"description":"ContextCancelledError:  response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"InternalServerError: Internal Server Error response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"BadGatewayError: Bad Gateway response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"schemas":{"FlexiBillingDailyRunsResponse":{"type":"object","properties":{"account":{"type":"string","description":"Account the read targeted; empty means all accounts"},"count":{"type":"integer","description":"Number of rows returned (after any limit)","format":"int64"},"date":{"type":"string","description":"Requested day"},"epoch_day":{"type":"integer","description":"Resolved 00:00 UTC Unix seconds for the date","format":"int64"},"rows":{"type":"array","items":{"$ref":"#/components/schemas/FlexiBillingDailyRun"}},"total_count":{"type":"integer","description":"Full number of rows for the day (and account), independent of limit","format":"int64"}},"description":"flexi_billing_events_daily_runs rows for a day","required":["date","epoch_day","count","total_count","rows"]},"FlexiBillingDailyRun":{"type":"object","properties":{"account":{"type":"string"},"created":{"type":"integer","format":"int64"},"epoch_day":{"type":"integer","format":"int64"},"id":{"type":"string"},"org":{"type":"string"},"parent_unique_id":{"type":"string"},"project":{"type":"string"},"provisioner":{"type":"string"},"provisioner_version":{"type":"string"},"status":{"type":"string","description":"Row delivery status","enum":["open","failed","success"]},"terragrunt_provider":{"type":"boolean"},"unique_key":{"type":"string"},"updated":{"type":"integer","format":"int64"},"workspace_id":{"type":"string"},"workspace_name":{"type":"string"}},"description":"A row stored in flexi_billing_events_daily_runs","required":["id","account","org","project","workspace_id","parent_unique_id","unique_key","provisioner","provisioner_version","workspace_name","terragrunt_provider","epoch_day","status","created","updated"]},"Error":{"type":"object","properties":{"fault":{"type":"boolean","description":"Is the error a server-side fault?"},"id":{"type":"string","description":"ID is a unique identifier for this particular occurrence of the problem."},"message":{"type":"string","description":"Message is a human-readable explanation specific to this occurrence of the problem."},"name":{"type":"string","description":"Name is the name of this class of errors."},"temporary":{"type":"boolean","description":"Is the error temporary?"},"timeout":{"type":"boolean","description":"Is the error a timeout?"}},"required":["name","id","message","temporary","timeout","fault"]}}}}
```

## Replay flexi billing delivery

> Enqueues Kafka delivery for one account, or the delivery sweep for all accounts. Delivery drains every open or failed row for an account regardless of day; date is validated but not used as a filter.

```json
{"openapi":"3.0.3","info":{"title":"Infrastructure as Code Management","version":"0.1.0"},"tags":[{"name":"flexi_billing","description":"Flexi Billing Service exposes internal, service-to-service-only operations for the flexi billing V3 pipeline: sanity reads of the ledger-reconstructed billable units, the flexi_billing_events_daily_runs rows, and the billable Ansible hosts for a day, plus replaying discovery, delivery, or Ansible host billing for a day."}],"servers":[{"url":"http://localhost:80"}],"paths":{"/api/flexi-billing/delivery":{"post":{"tags":["flexi_billing"],"summary":"Replay flexi billing delivery","description":"Enqueues Kafka delivery for one account, or the delivery sweep for all accounts. Delivery drains every open or failed row for an account regardless of day; date is validated but not used as a filter.","operationId":"flexi_billing#trigger-delivery","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TriggerFlexiBillingDeliveryRequest"}}}},"responses":{"202":{"description":"Accepted response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FlexiBillingTriggerResponse"}}}},"400":{"description":"BadRequestError: Bad Request response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"UnauthorizedError: Unauthorized response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"ForbiddenError: Forbidden response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"NotFoundError: Not Found response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"408":{"description":"TimeoutError: Request Timeout response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"ConflictError: Conflict response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"423":{"description":"LockedError: Locked response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"499":{"description":"ContextCancelledError:  response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"InternalServerError: Internal Server Error response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"BadGatewayError: Bad Gateway response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"schemas":{"TriggerFlexiBillingDeliveryRequest":{"type":"object","properties":{"account":{"type":"string","description":"Optional account identifier; empty means all accounts.","maxLength":128},"date":{"type":"string","description":"UTC calendar day to act on, in YYYY-MM-DD format; resolved to 00:00 UTC of that date. Must be a completed UTC day (before today)."},"force":{"type":"boolean","description":"When an identical job is already queued (e.g. waiting out a retry), make it run immediately instead of leaving it.","default":false}},"required":["date"]},"FlexiBillingTriggerResponse":{"type":"object","properties":{"account":{"type":"string","description":"Account the trigger targeted; empty means all accounts"},"date":{"type":"string","description":"Requested day"},"epoch_day":{"type":"integer","description":"Resolved 00:00 UTC Unix seconds for the date","format":"int64"},"job_id":{"type":"integer","description":"River job acted on","format":"int64"},"job_state":{"type":"string","description":"State of the River job after the trigger"},"message":{"type":"string","description":"Human-readable summary"},"outcome":{"type":"string","description":"What happened to the job","enum":["enqueued","already_queued","retried","running"]}},"description":"Result of a flexi billing trigger","required":["outcome","job_id","job_state","date","epoch_day","message"]},"Error":{"type":"object","properties":{"fault":{"type":"boolean","description":"Is the error a server-side fault?"},"id":{"type":"string","description":"ID is a unique identifier for this particular occurrence of the problem."},"message":{"type":"string","description":"Message is a human-readable explanation specific to this occurrence of the problem."},"name":{"type":"string","description":"Name is the name of this class of errors."},"temporary":{"type":"boolean","description":"Is the error temporary?"},"timeout":{"type":"boolean","description":"Is the error a timeout?"}},"required":["name","id","message","temporary","timeout","fault"]}}}}
```

## Replay flexi billing discovery for a day

> Enqueues discovery for one account, or the scheduler fan-out for all accounts, rebuilding flexi\_billing\_events\_daily\_runs from workspace\_history as of the end of the given date (UTC). The date must be a completed UTC day (before today). Idempotent: delivered rows are preserved and missing rows are filled in.

```json
{"openapi":"3.0.3","info":{"title":"Infrastructure as Code Management","version":"0.1.0"},"tags":[{"name":"flexi_billing","description":"Flexi Billing Service exposes internal, service-to-service-only operations for the flexi billing V3 pipeline: sanity reads of the ledger-reconstructed billable units, the flexi_billing_events_daily_runs rows, and the billable Ansible hosts for a day, plus replaying discovery, delivery, or Ansible host billing for a day."}],"servers":[{"url":"http://localhost:80"}],"paths":{"/api/flexi-billing/discovery":{"post":{"tags":["flexi_billing"],"summary":"Replay flexi billing discovery for a day","description":"Enqueues discovery for one account, or the scheduler fan-out for all accounts, rebuilding flexi_billing_events_daily_runs from workspace_history as of the end of the given date (UTC). The date must be a completed UTC day (before today). Idempotent: delivered rows are preserved and missing rows are filled in.","operationId":"flexi_billing#trigger-discovery","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TriggerFlexiBillingDiscoveryRequest"}}}},"responses":{"202":{"description":"Accepted response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FlexiBillingTriggerResponse"}}}},"400":{"description":"BadRequestError: Bad Request response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"UnauthorizedError: Unauthorized response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"ForbiddenError: Forbidden response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"NotFoundError: Not Found response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"408":{"description":"TimeoutError: Request Timeout response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"ConflictError: Conflict response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"423":{"description":"LockedError: Locked response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"499":{"description":"ContextCancelledError:  response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"InternalServerError: Internal Server Error response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"BadGatewayError: Bad Gateway response.","content":{"application/vnd.goa.error":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"schemas":{"TriggerFlexiBillingDiscoveryRequest":{"type":"object","properties":{"account":{"type":"string","description":"Optional account identifier; empty means all accounts.","maxLength":128},"date":{"type":"string","description":"UTC calendar day to act on, in YYYY-MM-DD format; resolved to 00:00 UTC of that date. Must be a completed UTC day (before today)."},"force":{"type":"boolean","description":"When an identical job is already queued (e.g. waiting out a retry), make it run immediately instead of leaving it.","default":false}},"required":["date"]},"FlexiBillingTriggerResponse":{"type":"object","properties":{"account":{"type":"string","description":"Account the trigger targeted; empty means all accounts"},"date":{"type":"string","description":"Requested day"},"epoch_day":{"type":"integer","description":"Resolved 00:00 UTC Unix seconds for the date","format":"int64"},"job_id":{"type":"integer","description":"River job acted on","format":"int64"},"job_state":{"type":"string","description":"State of the River job after the trigger"},"message":{"type":"string","description":"Human-readable summary"},"outcome":{"type":"string","description":"What happened to the job","enum":["enqueued","already_queued","retried","running"]}},"description":"Result of a flexi billing trigger","required":["outcome","job_id","job_state","date","epoch_day","message"]},"Error":{"type":"object","properties":{"fault":{"type":"boolean","description":"Is the error a server-side fault?"},"id":{"type":"string","description":"ID is a unique identifier for this particular occurrence of the problem."},"message":{"type":"string","description":"Message is a human-readable explanation specific to this occurrence of the problem."},"name":{"type":"string","description":"Name is the name of this class of errors."},"temporary":{"type":"boolean","description":"Is the error temporary?"},"timeout":{"type":"boolean","description":"Is the error a timeout?"}},"required":["name","id","message","temporary","timeout","fault"]}}}}
```
