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

# Preview optimizer run

> Plan which Etsy Ads listings to pause or move to Lower click cost, or which search terms to turn off, with the same optimizer as Alura's Etsy Ads page. A preview changes nothing on Etsy.

**Cost:** 1 API credit per live read.

> [!NOTE]
>
> Needs the seller's Chrome open somewhere, with the Alura extension and signed in to Etsy for this shop. The script or agent can run on another computer. An offline extension answers [`extension_offline`](https://docs.alura.io/errors/extension_offline); the [live status](https://docs.alura.io/api-reference/workspace/shops/live/get.md) can name a more specific connection problem. Errors cost no API credits. See [Chrome extension](https://docs.alura.io/api-reference/chrome-extension.md).

```bash
curl -X POST "https://api.alura.io/v1/workspace/ads/optimize/runs" \
  -H "Authorization: Bearer $ALURA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"shop_id": "22841907", "target": "listings"}'
```

Needs the `ads:read` scope and the **Etsy Ads** workspace permission. The preview is kept 30 minutes (`expires_at`), and [Get optimizer run](https://docs.alura.io/api-reference/workspace/ads/optimize/runs/get.md) reads it. To carry it out, use [Apply optimizer run](https://docs.alura.io/api-reference/workspace/ads/optimize/runs/apply.md).

## Choose what to plan

| `target` | Plans | Default strategy |
| - | - | - |
| `listings` | Which advertised listings to pause or move to Lower click cost | Budget Saver: pause listings that spend without selling. Needs no margin. |
| `search_terms` | Which search terms to turn off for a listing, Etsy's per-listing "irrelevant" toggle | Keyword Saver: turn off terms that spend without selling |

The strategy is `overrides.strategy`, else the saved [optimizer settings](https://docs.alura.io/api-reference/workspace/ads/optimize/settings/get.md), else the default. `basis` says which one ran.

A strategy that judges listings against break-even needs the shop's margin, saved or sent as `overrides.margin_pct`. Without it the answer is `422` [`margin_required`](https://docs.alura.io/errors/margin_required). `break_even_roas` comes from that margin and Etsy's fees for the shop's country.

## Large shops take several requests

One request makes at most 27 live reads (pages, stats and search terms), because a shop has 30 live Etsy reads a minute. While more is left:

1. The answer is `status: scanning`, with `scan` (how far it got) and `continuation`.
2. Wait `scan.retry_after_s`, then send `{"continuation": "..."}` alone.
3. Repeat until the same `id` answers `status: preview`, with the plan of the whole shop.

```bash Continue a scan
curl -X POST "https://api.alura.io/v1/workspace/ads/optimize/runs" \
  -H "Authorization: Bearer $ALURA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"continuation": "scan_01"}'
```

| Answer | Means |
| - | - |
| `429` [`live_rate_limited`](https://docs.alura.io/errors/live_rate_limited) | You sent the continuation too early. Nothing was read, it is free, and the scan is kept. |
| `410` [`optimize_run_expired`](https://docs.alura.io/errors/optimize_run_expired) | The scan didn't finish within 30 minutes (`expires_at`) |

## What gets planned

The shop's advertised listings are read live from Etsy, highest spend first, until no remaining listing can match or 60 pages of 50 are read (3000 listings, as Alura's Etsy Ads page reads). Past that, `coverage.complete` is `false` with `scan_truncated`.

The highest-spend listings come first, and `capped` says when more matched.

| Limit | Value |
| - | - |
| Actions by default | The strategy's own cap, at most 120, which is what one apply sends. `max_actions_capped` says when that lowered it. |
| Actions with `overrides.max_actions` | Up to 240, for a preview only |

## Read the plan

`projected_monthly_spend_freed` is the paused listings' spend as 30 days: spend freed, not guaranteed cash saved.

> [!NOTE]
>
> Spend Etsy didn't report is never added as 0. It is counted in `spend_unknown_count`, and above 0 the amount is a lower bound. Listings with a number or protection Alura couldn't read are counted in `coverage.unjudgeable`, never judged as zero.

## Search terms

With `target: search_terms`, Alura reads the search terms of at most 150 advertised listings (`coverage.search_terms`), each over Etsy's last 31 days (`period`). More than 150 sets `coverage.complete: false` with `scan_truncated`.

Terms already off count in `already_off`. A plan holds at most 7 terms by default, which is what one apply sends.

## Limits

`429` [`live_rate_limited`](https://docs.alura.io/errors/live_rate_limited) means the shop had too many live reads: more than 2 at a time or 30 a minute. Wait for `Retry-After`.

Each page, the campaign's stats and each listing's search terms is one live read, up to 27 a request. A request that could not read Etsy is free. See [Credits and limits](https://docs.alura.io/api-reference/credits-and-limits.md).


## OpenAPI

````yaml /openapi.json post /v1/workspace/ads/optimize/runs
openapi: 3.1.0
info:
  title: Alura API
  version: 1.0.0
  description: Etsy market research for scripts and AI assistants.
servers:
  - url: https://api.alura.io
security:
  - apiKey: []
paths:
  /v1/workspace/ads/optimize/runs:
    post:
      summary: Preview optimizer run
      description: >-
        Plans which of your shop's Etsy Ads listings to pause or move to Lower
        click cost (`target: listings`), or which search terms to turn off for a
        listing (`target: search_terms`, Etsy's per-listing "irrelevant"
        toggle), with the same optimizer as Alura's Etsy Ads page, and changes
        nothing. The strategy is `overrides.strategy`, else the saved optimizer
        settings, else Budget Saver (pauses listings that spend without selling;
        needs no margin); `basis` says which. A strategy that judges listings
        against break-even needs the shop's margin, saved or sent as
        `overrides.margin_pct` (422 `margin_required` otherwise);
        `break_even_roas` is its break-even ROAS. The shop's advertised listings
        are read live from Etsy, up to 3000 (as Alura's Etsy Ads page reads;
        past them `coverage.complete: false` with `scan_truncated`). **A large
        shop takes several requests:** one request reads at most 27 pages, stats
        and search terms (the shop's 30 live Etsy reads a minute). While more is
        left it answers `status: scanning` with `scan` (how far it got) and
        `continuation`: send `{"continuation": ...}` alone after
        `scan.retry_after_s`, and repeat until the same `id` answers `status:
        preview` with the plan of the whole shop. Sent earlier it is 429
        `live_rate_limited` (nothing read, free; the scan is kept); a scan not
        finished within 30 minutes (`expires_at`) is 410 `optimize_run_expired`.
        By default at most the strategy's own cap, capped to 120 (what one apply
        sends; `max_actions_capped` says when that lowered it);
        `overrides.max_actions` plans up to 240 for a preview only. The
        highest-spend listings first, `capped` when more matched.
        `projected_monthly_spend_freed` is the paused listings' spend per month:
        spend freed, not guaranteed cash saved; spend Etsy didn't report is
        never added as 0 but counted in `spend_unknown_count`, and above 0 the
        amount is a lower bound. Listings with a number or protection Alura
        could not read are counted in `coverage.unjudgeable`, never judged as
        zero. The preview is kept 30 minutes (`expires_at`): `GET
        /v1/workspace/ads/optimize/runs/{id}` reads it. Needs Chrome open with
        the Alura extension and logged into the shop on Etsy, the `ads:read`
        scope and the Etsy Ads permission. Costs 1 API credit per live read
        (each page, the campaign's stats and each listing's search terms; up to
        27 a request); a request that could not read Etsy is free. **Search
        terms:** the search-terms strategy of the settings, else Keyword Saver
        (turns off terms that spend without selling); the terms of at most 150
        listings are read (`coverage.search_terms`; more: `coverage.complete:
        false`, `scan_truncated`), each over Etsy's last 31 days (`period`).
        Terms already off count in `already_off`. By default at most 7 terms
        (what one apply sends).


        Cost: 1 API credit per live read.
      operationId: workspace.ads.optimize.runs.preview
      parameters: []
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                continuation:
                  type: string
                  minLength: 1
                  maxLength: 80
                  pattern: ^[A-Za-z0-9_-]{1,80}$
                  description: >-
                    A scanning preview's `continuation`: reads more of its shop,
                    then plans. Sent alone.
                shop_id:
                  description: >-
                    The Etsy shop ID of one of the workspace's connected shops;
                    optional when the workspace has one. A shop outside the
                    workspace is 404.
                  type: string
                  pattern: ^[0-9]{1,20}$
                target:
                  description: >-
                    What to optimize: `listings` (pause or lower the click cost
                    of advertised listings) or `search_terms` (turn a search
                    term off for one listing, Etsy's per-listing "irrelevant"
                    toggle: the search-terms strategy of the settings, else
                    Keyword Saver). Required unless `continuation` is sent.
                  type: string
                  enum:
                    - listings
                    - search_terms
                listing_ids:
                  description: >-
                    Plan only for these listings (at most 100); the whole shop
                    is still scanned, and `coverage.listing_ids_not_scanned`
                    names any the scan did not reach (for `search_terms`: any
                    whose terms were not read).
                  minItems: 1
                  maxItems: 100
                  type: array
                  items:
                    type: string
                    pattern: ^[0-9]{1,20}$
                period:
                  description: >-
                    The stats period the rules judge: `last_30_days`,
                    `last_3_months`, `last_12_months` or `all_time` (Etsy's last
                    730 days, as Alura's Etsy Ads page). Default: the strategy's
                    own period.
                  type: string
                  enum:
                    - last_30_days
                    - last_3_months
                    - last_12_months
                    - all_time
                overrides:
                  type: object
                  properties:
                    margin_pct:
                      description: >-
                        The shop's margin for this run, in percent (0-95): what
                        is left of revenue after making, packaging and shipping,
                        before Etsy's fees and ads. Default: the saved margin.
                      type: number
                      minimum: 0
                      maximum: 95
                    strategy:
                      description: >-
                        A whole strategy for this run (the shape of a strategy
                        in the optimizer settings, snake_case; camelCase keys
                        are still taken, deprecated): a listings strategy for
                        `listings`, a search-terms one (`mode: "keywords"`) for
                        `search_terms`. Default: the saved strategy, else Budget
                        Saver (listings) or Keyword Saver (search terms).
                      type: object
                      properties:
                        id:
                          type: string
                          minLength: 1
                          maxLength: 80
                        name:
                          type: string
                          minLength: 1
                          maxLength: 200
                        description:
                          type: string
                          maxLength: 1000
                        mode:
                          type: string
                          enum:
                            - listings
                            - keywords
                        period:
                          type: string
                          enum:
                            - all_time
                            - last_12_months
                            - last_3_months
                            - last_30_days
                        action:
                          type: string
                          enum:
                            - pause
                            - lower_click_cost
                        rule_groups:
                          maxItems: 20
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: string
                                minLength: 1
                                maxLength: 80
                              conditions:
                                maxItems: 20
                                type: array
                                items:
                                  type: object
                                  properties:
                                    factor:
                                      type: string
                                      enum:
                                        - spend
                                        - roas
                                        - orders
                                        - revenue
                                        - clicks
                                        - views
                                        - ctr
                                    op:
                                      type: string
                                      enum:
                                        - gt
                                        - lt
                                        - eq
                                    value:
                                      type: number
                                    relative_to:
                                      type: string
                                      const: break_even
                                    margin_pct:
                                      type: number
                                      minimum: 0
                                      maximum: 95
                                    unconverted:
                                      type: string
                                      const: USD
                                  required:
                                    - factor
                                    - op
                                    - value
                                  additionalProperties: false
                            required:
                              - id
                              - conditions
                            additionalProperties: false
                        exclusions:
                          type: object
                          properties:
                            listing_ids:
                              maxItems: 5000
                              type: array
                              items:
                                type: integer
                                exclusiveMinimum: 0
                            section_ids:
                              maxItems: 500
                              type: array
                              items:
                                type: integer
                                exclusiveMinimum: 0
                            min_price:
                              type: number
                              minimum: 0
                            max_price:
                              type: number
                              minimum: 0
                            skip_digital:
                              type: boolean
                          required:
                            - listing_ids
                            - section_ids
                          additionalProperties: false
                        overrides:
                          maxItems: 20
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: string
                                minLength: 1
                                maxLength: 80
                              label:
                                type: string
                                maxLength: 200
                              match:
                                type: object
                                properties:
                                  section_ids:
                                    maxItems: 500
                                    type: array
                                    items:
                                      type: integer
                                      exclusiveMinimum: 0
                                  listing_ids:
                                    maxItems: 5000
                                    type: array
                                    items:
                                      type: integer
                                      exclusiveMinimum: 0
                                  is_digital:
                                    type: boolean
                                  price_gte:
                                    type: number
                                    minimum: 0
                                  price_lte:
                                    type: number
                                    minimum: 0
                                additionalProperties: false
                              rule_groups:
                                maxItems: 20
                                type: array
                                items:
                                  type: object
                                  properties:
                                    id:
                                      type: string
                                      minLength: 1
                                      maxLength: 80
                                    conditions:
                                      maxItems: 20
                                      type: array
                                      items:
                                        type: object
                                        properties:
                                          factor:
                                            type: string
                                            enum:
                                              - spend
                                              - roas
                                              - orders
                                              - revenue
                                              - clicks
                                              - views
                                              - ctr
                                          op:
                                            type: string
                                            enum:
                                              - gt
                                              - lt
                                              - eq
                                          value:
                                            type: number
                                          relative_to:
                                            type: string
                                            const: break_even
                                          margin_pct:
                                            type: number
                                            minimum: 0
                                            maximum: 95
                                          unconverted:
                                            type: string
                                            const: USD
                                        required:
                                          - factor
                                          - op
                                          - value
                                        additionalProperties: false
                                  required:
                                    - id
                                    - conditions
                                  additionalProperties: false
                              action:
                                type: string
                                enum:
                                  - pause
                                  - lower_click_cost
                            required:
                              - id
                              - label
                              - match
                              - rule_groups
                            additionalProperties: false
                        guardrails:
                          type: object
                          properties:
                            min_clicks:
                              type: integer
                              minimum: 0
                            rule_of_three:
                              type: boolean
                            grace_days:
                              type: integer
                              minimum: 0
                            max_actions_per_run:
                              type: integer
                              minimum: 1
                            keyword_listing_cap:
                              type: integer
                              minimum: 1
                          additionalProperties: false
                        is_custom:
                          type: boolean
                        model_version:
                          type: integer
                          exclusiveMinimum: 0
                      required:
                        - id
                        - name
                        - period
                        - action
                        - rule_groups
                      additionalProperties: false
                    max_actions:
                      description: >-
                        The most actions this run may plan (1-240). Default: the
                        strategy's own cap (else 50), at most what one apply
                        sends (120 listings, 7 search terms;
                        `max_actions_capped` says when that lowered it). Above
                        that the preview plans them, but its apply is refused.
                      type: integer
                      minimum: 1
                      maximum: 240
                  additionalProperties: false
              additionalProperties: false
            example:
              shop_id: '22841907'
              target: listings
      responses:
        '200':
          description: OK
          headers:
            Request-Id:
              $ref: '#/components/headers/Request-Id'
            Alura-Credits-Cost:
              $ref: '#/components/headers/Alura-Credits-Cost'
            Alura-Credits-Remaining:
              $ref: '#/components/headers/Alura-Credits-Remaining'
          content:
            application/json:
              schema:
                anyOf:
                  - type: object
                    properties:
                      object:
                        type: string
                        const: workspace.ads_optimize_run
                      id:
                        type: string
                        description: >-
                          The run ID: `GET /v1/workspace/ads/optimize/runs/{id}`
                          reads it while it is kept.
                      status:
                        type: string
                        const: preview
                        description: '`preview`: planned only; nothing was changed on Etsy.'
                      shop_id:
                        type: string
                      target:
                        type: string
                        enum:
                          - listings
                          - search_terms
                      created_at:
                        type: string
                        description: ISO 8601, UTC.
                      expires_at:
                        type: string
                        description: >-
                          When the preview is dropped: after it, its GET is 410
                          `optimize_run_expired`.
                      basis:
                        type: string
                        enum:
                          - explicit
                          - saved
                          - default
                        description: >-
                          Where the strategy came from: `explicit`
                          (`overrides.strategy`), `saved` (the optimizer
                          settings), `default` (Budget Saver, or Keyword Saver
                          for search terms: no settings saved).
                      strategy:
                        type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                        description: >-
                          The strategy the plan used (the shape of a strategy in
                          the optimizer settings), with the run's period and
                          action cap.
                      period:
                        type: object
                        properties:
                          from:
                            type: string
                          to:
                            type: string
                        required:
                          - from
                          - to
                        additionalProperties: false
                        description: >-
                          The days judged, on Etsy's calendar (US Eastern); for
                          search terms, the window their numbers cover (Etsy's
                          rolling last 31 days and today).
                      margin_pct:
                        description: >-
                          The shop margin the plan used; null when none is saved
                          or given.
                        type:
                          - number
                          - 'null'
                      break_even_roas:
                        description: >-
                          The shop margin's break-even ROAS: below it, ads lose
                          money at this margin. A floor: a listing's own can be
                          higher. null without a margin, when it is unknown, or
                          when no ROAS breaks even at this margin.
                        type:
                          - number
                          - 'null'
                      actions:
                        type: array
                        items:
                          type: object
                          properties:
                            listing_id:
                              type: string
                              description: The Etsy listing ID, as a string.
                            title:
                              type: string
                              description: The listing's title.
                            action:
                              type: string
                              enum:
                                - pause
                                - lower_click_cost
                                - mark_irrelevant
                              description: >-
                                `pause`: stop advertising the listing;
                                `lower_click_cost`: move it to the Lower click
                                cost strategy; `mark_irrelevant`: turn the
                                search term `query` off for this listing.
                            query:
                              description: >-
                                The search term a `mark_irrelevant` action turns
                                off (as Etsy names it); null otherwise.
                              type:
                                - string
                                - 'null'
                            reason:
                              type: string
                              description: Why the rules matched, in words.
                            override:
                              description: >-
                                The label of the strategy's override whose rules
                                matched; null for the base rules.
                              type:
                                - string
                                - 'null'
                            prev_strategy:
                              anyOf:
                                - type: string
                                  enum:
                                    - efficient
                                    - lower_click_cost
                                    - greater_visibility
                                - type: 'null'
                              description: >-
                                The listing's strategy now (what an undo
                                restores); null when Etsy did not say.
                            metrics:
                              type: object
                              properties:
                                impressions:
                                  anyOf:
                                    - type: integer
                                    - type: 'null'
                                  description: >-
                                    Times the ads were shown; null when Etsy did
                                    not give it.
                                clicks:
                                  anyOf:
                                    - type: integer
                                    - type: 'null'
                                  description: >-
                                    Clicks on the ads; null when Etsy did not
                                    give it.
                                click_rate:
                                  description: >-
                                    Clicks ÷ impressions (0.0162 for 1.62%),
                                    from the counts; null when there were no
                                    impressions or a count is unknown.
                                  type:
                                    - number
                                    - 'null'
                                spend:
                                  anyOf:
                                    - type: object
                                      properties:
                                        amount:
                                          type: string
                                          description: >-
                                            Decimal string with the currency's
                                            decimals.
                                        currency:
                                          type: string
                                          description: >-
                                            ISO 4217. Etsy Ads money (budget, spend,
                                            revenue) is `USD` for every shop,
                                            whatever the shop's own currency; a
                                            listing's price is in the currency Etsy
                                            names for it.
                                      required:
                                        - amount
                                        - currency
                                      additionalProperties: false
                                      description: An amount of money.
                                    - type: 'null'
                                  description: >-
                                    What the ads cost, in US dollars; null when
                                    Etsy did not give it.
                                orders:
                                  anyOf:
                                    - type: integer
                                    - type: 'null'
                                  description: >-
                                    Orders Etsy attributes to the ads; null when
                                    Etsy did not give it.
                                revenue:
                                  anyOf:
                                    - type: object
                                      properties:
                                        amount:
                                          type: string
                                          description: >-
                                            Decimal string with the currency's
                                            decimals.
                                        currency:
                                          type: string
                                          description: >-
                                            ISO 4217. Etsy Ads money (budget, spend,
                                            revenue) is `USD` for every shop,
                                            whatever the shop's own currency; a
                                            listing's price is in the currency Etsy
                                            names for it.
                                      required:
                                        - amount
                                        - currency
                                      additionalProperties: false
                                      description: An amount of money.
                                    - type: 'null'
                                  description: >-
                                    Revenue from those orders, in US dollars;
                                    null when Etsy did not give it.
                                roas:
                                  description: >-
                                    Return on ad spend: revenue ÷ spend; null
                                    when nothing was spent or either is unknown.
                                  type:
                                    - number
                                    - 'null'
                              required:
                                - impressions
                                - clicks
                                - click_rate
                                - spend
                                - orders
                                - revenue
                                - roas
                              additionalProperties: false
                              description: >-
                                The listing over the period (for
                                `mark_irrelevant`: the search term on this
                                listing).
                          required:
                            - listing_id
                            - title
                            - action
                            - query
                            - reason
                            - override
                            - prev_strategy
                            - metrics
                          additionalProperties: false
                        description: The planned changes, highest spend first.
                      held_back:
                        default: []
                        description: >-
                          What the rules matched but a guardrail held back
                          (codes of kind `guardrail`, except `run_cap`:
                          `capped_count` counts those), highest spend first, at
                          most 20 (the `held_back` notice counts them all).
                          Nothing here is changed by an apply; a seller who
                          wants them acted on changes the strategy's guardrails.
                        type: array
                        items:
                          type: object
                          properties:
                            listing_id:
                              type: string
                              description: The Etsy listing ID, as a string.
                            title:
                              type: string
                              description: The listing's title.
                            query:
                              description: >-
                                For `search_terms`: the search term; null for
                                listings.
                              type:
                                - string
                                - 'null'
                            code:
                              type: string
                              enum:
                                - min_clicks
                                - rule_of_three
                                - grace_period
                                - run_cap
                                - already_lower_click_cost
                                - query_too_long
                                - metric_unknown
                                - conversion_rate_unknown
                                - protection_unknown
                                - unexpected_data
                              description: >-
                                Why it got no action. Guardrails (the rules
                                matched; a guardrail held it back): `min_clicks`
                                (fewer clicks than the strategy's floor),
                                `rule_of_three` (no sale yet, but too few clicks
                                for that to count as evidence at the shop's
                                conversion rate), `grace_period` (newer than the
                                strategy's grace period), `run_cap` (past the
                                run's action cap). Rules (the rules matched;
                                nothing to change): `already_lower_click_cost`,
                                `query_too_long`. Data missing (not judged):
                                `metric_unknown` (Etsy did not report a number
                                the rules need), `conversion_rate_unknown`,
                                `protection_unknown` (price, digital status,
                                section or age could not be checked),
                                `unexpected_data`. New codes may be added.
                            reason:
                              type: string
                              description: Why it was held back, in words.
                            clicks_needed:
                              anyOf:
                                - type: integer
                                - type: 'null'
                              description: >-
                                For `rule_of_three`: the clicks with no sale at
                                which the rules would act on it; null otherwise.
                            metrics:
                              type: object
                              properties:
                                impressions:
                                  anyOf:
                                    - type: integer
                                    - type: 'null'
                                  description: >-
                                    Times the ads were shown; null when Etsy did
                                    not give it.
                                clicks:
                                  anyOf:
                                    - type: integer
                                    - type: 'null'
                                  description: >-
                                    Clicks on the ads; null when Etsy did not
                                    give it.
                                click_rate:
                                  description: >-
                                    Clicks ÷ impressions (0.0162 for 1.62%),
                                    from the counts; null when there were no
                                    impressions or a count is unknown.
                                  type:
                                    - number
                                    - 'null'
                                spend:
                                  anyOf:
                                    - type: object
                                      properties:
                                        amount:
                                          type: string
                                          description: >-
                                            Decimal string with the currency's
                                            decimals.
                                        currency:
                                          type: string
                                          description: >-
                                            ISO 4217. Etsy Ads money (budget, spend,
                                            revenue) is `USD` for every shop,
                                            whatever the shop's own currency; a
                                            listing's price is in the currency Etsy
                                            names for it.
                                      required:
                                        - amount
                                        - currency
                                      additionalProperties: false
                                      description: An amount of money.
                                    - type: 'null'
                                  description: >-
                                    What the ads cost, in US dollars; null when
                                    Etsy did not give it.
                                orders:
                                  anyOf:
                                    - type: integer
                                    - type: 'null'
                                  description: >-
                                    Orders Etsy attributes to the ads; null when
                                    Etsy did not give it.
                                revenue:
                                  anyOf:
                                    - type: object
                                      properties:
                                        amount:
                                          type: string
                                          description: >-
                                            Decimal string with the currency's
                                            decimals.
                                        currency:
                                          type: string
                                          description: >-
                                            ISO 4217. Etsy Ads money (budget, spend,
                                            revenue) is `USD` for every shop,
                                            whatever the shop's own currency; a
                                            listing's price is in the currency Etsy
                                            names for it.
                                      required:
                                        - amount
                                        - currency
                                      additionalProperties: false
                                      description: An amount of money.
                                    - type: 'null'
                                  description: >-
                                    Revenue from those orders, in US dollars;
                                    null when Etsy did not give it.
                                roas:
                                  description: >-
                                    Return on ad spend: revenue ÷ spend; null
                                    when nothing was spent or either is unknown.
                                  type:
                                    - number
                                    - 'null'
                              required:
                                - impressions
                                - clicks
                                - click_rate
                                - spend
                                - orders
                                - revenue
                                - roas
                              additionalProperties: false
                              description: >-
                                The listing over the period (for search terms:
                                the term on this listing).
                          required:
                            - listing_id
                            - title
                            - query
                            - code
                            - reason
                            - clicks_needed
                            - metrics
                          additionalProperties: false
                      capped:
                        type: boolean
                        description: >-
                          true when more listings matched than the action cap:
                          the highest-spend ones were kept.
                      max_actions_capped:
                        type: boolean
                        description: >-
                          true when the strategy's own action cap (or the
                          default) was above what one apply sends (120 listings,
                          7 search terms), so this preview planned at most that;
                          send `overrides.max_actions` to plan more (preview
                          only: an apply sends no more). The saved settings are
                          unchanged.
                      capped_count:
                        type: integer
                        description: >-
                          Listings (or search terms) that matched beyond the cap
                          (0 when not capped).
                      projected_monthly_spend_freed:
                        anyOf:
                          - type: object
                            properties:
                              amount:
                                type: string
                                description: Decimal string with the currency's decimals.
                              currency:
                                type: string
                                description: >-
                                  ISO 4217. Etsy Ads money (budget, spend,
                                  revenue) is `USD` for every shop, whatever the
                                  shop's own currency; a listing's price is in
                                  the currency Etsy names for it.
                            required:
                              - amount
                              - currency
                            additionalProperties: false
                            description: An amount of money.
                          - type: 'null'
                        description: >-
                          The paused listings' (or turned-off terms') spend over
                          the period, as 30 days: ad spend freed, not guaranteed
                          cash saved (the daily budget is shared, so Etsy may
                          spend it on other listings). Only spend Etsy reported
                          is added: with `spend_unknown_count` above 0 this is a
                          lower bound (at least this much). In US dollars (Etsy
                          Ads money for every shop); null when it is unknown.
                      spend_unknown_count:
                        type: integer
                        description: >-
                          Paused listings whose spend Etsy didn't report: left
                          out of `projected_monthly_spend_freed`, never added as
                          0, so above 0 that amount is "at least".
                      coverage:
                        type: object
                        properties:
                          listings_total:
                            anyOf:
                              - type: integer
                              - type: 'null'
                            description: >-
                              Etsy's count of the shop's advertised listings;
                              null when Etsy did not give it.
                          listings_scanned:
                            type: integer
                            description: Listings read and judged (after removing repeats).
                          pages_read:
                            type: integer
                          complete:
                            type: boolean
                            description: >-
                              true when every listing that could match was read;
                              false when the scan stopped at its page cap
                              (notice `scan_truncated`): the plan covers part of
                              the shop.
                          stopped_at_spend_floor:
                            type: boolean
                            description: >-
                              true when the scan stopped early because no
                              remaining listing could match any rule (the plan
                              is still whole).
                          eligible:
                            type: integer
                            description: Scanned listings no exclusion left out.
                          excluded:
                            type: array
                            items:
                              type: object
                              properties:
                                reason:
                                  type: string
                                count:
                                  type: integer
                              required:
                                - reason
                                - count
                              additionalProperties: false
                            description: Listings left out by an exclusion, by reason.
                          skipped:
                            type: integer
                            description: >-
                              Listings (or search terms) the rules matched but
                              did not act on, and those not judged because data
                              was missing: `skipped_by_reason` counts them by
                              code. A listing no rule matches is not skipped.
                          skipped_by_reason:
                            default: []
                            description: '`skipped` by code, most first.'
                            type: array
                            items:
                              type: object
                              properties:
                                code:
                                  type: string
                                  enum:
                                    - min_clicks
                                    - rule_of_three
                                    - grace_period
                                    - run_cap
                                    - already_lower_click_cost
                                    - query_too_long
                                    - metric_unknown
                                    - conversion_rate_unknown
                                    - protection_unknown
                                    - unexpected_data
                                  description: >-
                                    Why it got no action. Guardrails (the rules
                                    matched; a guardrail held it back):
                                    `min_clicks` (fewer clicks than the
                                    strategy's floor), `rule_of_three` (no sale
                                    yet, but too few clicks for that to count as
                                    evidence at the shop's conversion rate),
                                    `grace_period` (newer than the strategy's
                                    grace period), `run_cap` (past the run's
                                    action cap). Rules (the rules matched;
                                    nothing to change):
                                    `already_lower_click_cost`,
                                    `query_too_long`. Data missing (not judged):
                                    `metric_unknown` (Etsy did not report a
                                    number the rules need),
                                    `conversion_rate_unknown`,
                                    `protection_unknown` (price, digital status,
                                    section or age could not be checked),
                                    `unexpected_data`. New codes may be added.
                                kind:
                                  type: string
                                  enum:
                                    - guardrail
                                    - rule
                                    - data_missing
                                  description: >-
                                    `guardrail`: the rules matched and a
                                    guardrail held it back; `rule`: the rules
                                    matched, nothing to change; `data_missing`:
                                    not judged.
                                count:
                                  type: integer
                              required:
                                - code
                                - kind
                                - count
                              additionalProperties: false
                          unjudgeable:
                            type: integer
                            description: >-
                              Listings not judged at all because a number or a
                              protection was unknown (never read as zero).
                          unreadable:
                            type: integer
                            description: >-
                              Rows Etsy sent that Alura could not read: never
                              judged.
                          listing_ids_not_scanned:
                            type: array
                            items:
                              type: string
                            description: >-
                              Of `listing_ids`, those the scan did not reach
                              (not advertised, unable to match the rules, or
                              past the page cap); for search terms, those whose
                              terms were not read.
                          search_terms:
                            anyOf:
                              - type: object
                                properties:
                                  candidate_listings:
                                    type: integer
                                    description: Listings that could hold a matching term.
                                  listings_read:
                                    type: integer
                                    description: >-
                                      Of them, listings whose search terms Etsy
                                      served.
                                  failed_reads:
                                    type: integer
                                    description: >-
                                      Of them, listings whose terms Etsy did not
                                      serve: never judged (notice
                                      `search_terms_unread`).
                                  below_spend_floor:
                                    type: integer
                                    description: >-
                                      Listings none of whose terms could match
                                      the rules: not read.
                                  unjudgeable_listings:
                                    type: integer
                                    description: >-
                                      Listings not read because a protection
                                      (age, digital, section) was unknown.
                                  terms_judged:
                                    type: integer
                                    description: >-
                                      Search terms judged (already-off ones
                                      excluded).
                                  already_off:
                                    type: integer
                                    description: >-
                                      Search terms Etsy already shows off: never
                                      judged again.
                                  unreadable_terms:
                                    type: integer
                                    description: >-
                                      Search term rows Alura could not read:
                                      never judged.
                                  too_long:
                                    type: integer
                                    description: >-
                                      Matching search terms longer than 200
                                      characters, which Etsy's toggle can't
                                      take: skipped (notice `terms_too_long`).
                                required:
                                  - candidate_listings
                                  - listings_read
                                  - failed_reads
                                  - below_spend_floor
                                  - unjudgeable_listings
                                  - terms_judged
                                  - already_off
                                  - unreadable_terms
                                  - too_long
                                additionalProperties: false
                              - type: 'null'
                            description: >-
                              For `search_terms`: how the candidate listings and
                              their terms were read; null for `listings`.
                        required:
                          - listings_total
                          - listings_scanned
                          - pages_read
                          - complete
                          - stopped_at_spend_floor
                          - eligible
                          - excluded
                          - skipped
                          - skipped_by_reason
                          - unjudgeable
                          - unreadable
                          - listing_ids_not_scanned
                          - search_terms
                        additionalProperties: false
                      notices:
                        type: array
                        items:
                          type: object
                          properties:
                            code:
                              type: string
                              description: >-
                                `held_back` (listings or search terms the rules
                                matched were held back by a guardrail: listed in
                                `held_back`), `scan_truncated` (the scan stopped
                                at its page cap, or, for search terms, more
                                listings could hold a matching term than one
                                preview reads: the plan covers part of the
                                shop), `no_ads_campaign`,
                                `conversion_rate_unknown` (zero-sale listings
                                were left unjudged), `fees_unknown` (break-even
                                is unknown), `sections_unavailable`,
                                `digital_unavailable`, `ages_unavailable`
                                (listings a rule needs them for were skipped),
                                `rows_unreadable`; for search terms
                                `search_terms_unread` (some listings' terms were
                                not served: not judged), `terms_unreadable`,
                                `terms_too_long`, `search_terms_window` (Etsy
                                reports terms for its last 31 days only). New
                                codes may be added.
                            detail:
                              type: string
                          required:
                            - code
                            - detail
                          additionalProperties: false
                      plan_hash:
                        type: string
                        description: >-
                          The plan's hash (its actions and everything they were
                          decided on). Send it with the apply (`plan_hash`): the
                          apply is refused, nothing sent, unless it is still
                          this plan.
                      fetched_at:
                        anyOf:
                          - type: string
                            description: ISO 8601, UTC.
                          - type: 'null'
                        description: >-
                          When Alura read the scan from Etsy; null when nothing
                          was read.
                      source:
                        type: string
                        const: live
                    required:
                      - object
                      - id
                      - status
                      - shop_id
                      - target
                      - created_at
                      - expires_at
                      - basis
                      - strategy
                      - period
                      - margin_pct
                      - break_even_roas
                      - actions
                      - held_back
                      - capped
                      - max_actions_capped
                      - capped_count
                      - projected_monthly_spend_freed
                      - spend_unknown_count
                      - coverage
                      - notices
                      - plan_hash
                      - fetched_at
                      - source
                    additionalProperties: false
                  - type: object
                    properties:
                      object:
                        type: string
                        const: workspace.ads_optimize_run
                      id:
                        type: string
                        description: 'The run ID: the preview it becomes keeps it.'
                      status:
                        type: string
                        const: scanning
                        description: >-
                          `scanning`: the shop is still being read and nothing
                          is planned yet. Send `continuation` back to read more.
                      shop_id:
                        type: string
                      target:
                        type: string
                        enum:
                          - listings
                          - search_terms
                      created_at:
                        type: string
                        description: ISO 8601, UTC.
                      expires_at:
                        type: string
                        description: >-
                          When the scan is dropped: one not finished by then is
                          410 `optimize_run_expired` (preview again).
                      continuation:
                        type: string
                        description: >-
                          Send it back as `continuation` (alone) to read more:
                          each request reads what the shop's minute of live Etsy
                          reads allows.
                      scan:
                        type: object
                        properties:
                          listings_read:
                            type: integer
                            description: >-
                              Advertised listings read so far (after removing
                              repeats).
                          listings_total:
                            anyOf:
                              - type: integer
                              - type: 'null'
                            description: >-
                              Etsy's count of the shop's advertised listings;
                              null when Etsy did not give it.
                          pages_read:
                            type: integer
                          search_terms:
                            anyOf:
                              - type: object
                                properties:
                                  listings_read:
                                    type: integer
                                    description: >-
                                      Listings whose search terms were read so
                                      far.
                                  listings_total:
                                    type: integer
                                    description: >-
                                      Listings whose search terms the preview
                                      reads.
                                required:
                                  - listings_read
                                  - listings_total
                                additionalProperties: false
                              - type: 'null'
                            description: >-
                              For `search_terms`, once the listings to read the
                              terms of are known; null otherwise.
                          retry_after_s:
                            type: integer
                            description: >-
                              Seconds to wait before sending `continuation`: the
                              shop's live Etsy reads of the last minute are used
                              up until then. Sent earlier, it is 429
                              `live_rate_limited` (nothing read, free).
                        required:
                          - listings_read
                          - listings_total
                          - pages_read
                          - search_terms
                          - retry_after_s
                        additionalProperties: false
                        description: How far the scan got.
                      fetched_at:
                        anyOf:
                          - type: string
                            description: ISO 8601, UTC.
                          - type: 'null'
                        description: >-
                          When Alura first read the scan from Etsy; null when
                          nothing was read.
                      source:
                        type: string
                        const: live
                    required:
                      - object
                      - id
                      - status
                      - shop_id
                      - target
                      - created_at
                      - expires_at
                      - continuation
                      - scan
                      - fetched_at
                      - source
                    additionalProperties: false
              example:
                object: workspace.ads_optimize_run
                id: 0b9f0e3a-6d2c-4f0e-9a51-3c2d8e7f1a42
                status: preview
                shop_id: '22841907'
                target: listings
                created_at: '2026-10-17T12:00:00.000Z'
                expires_at: '2026-10-17T12:30:00.000Z'
                basis: saved
                strategy:
                  id: budget-saver
                  name: Budget Saver
                  description: >-
                    Pause only listings that spend but never sell. No margin
                    needed.
                  period: all_time
                  action: pause
                  rule_groups:
                    - id: budget-saver-1
                      conditions:
                        - factor: spend
                          op: gt
                          value: 10
                        - factor: orders
                          op: eq
                          value: 0
                  guardrails:
                    min_clicks: 10
                    rule_of_three: true
                    max_actions_per_run: 50
                  model_version: 1
                period:
                  from: '2024-10-18'
                  to: '2026-10-17'
                margin_pct: null
                break_even_roas: null
                actions:
                  - listing_id: '1834720563'
                    title: Hand-thrown ceramic mug
                    action: pause
                    query: null
                    reason: Spend $42.50 > $10.00 and Orders 0 = 0
                    override: null
                    prev_strategy: efficient
                    metrics:
                      impressions: 2140
                      clicks: 31
                      click_rate: 0.0145
                      spend:
                        amount: '42.50'
                        currency: USD
                      orders: 0
                      revenue:
                        amount: '0.00'
                        currency: USD
                      roas: 0
                held_back:
                  - listing_id: '1834720564'
                    title: Speckled ceramic bowl
                    query: null
                    code: rule_of_three
                    reason: 'Not enough evidence yet: 18 clicks with no sale.'
                    clicks_needed: 143
                    metrics:
                      impressions: 1210
                      clicks: 18
                      click_rate: 0.0149
                      spend:
                        amount: '12.00'
                        currency: USD
                      orders: 0
                      revenue:
                        amount: '0.00'
                        currency: USD
                      roas: 0
                capped: false
                max_actions_capped: false
                capped_count: 0
                projected_monthly_spend_freed:
                  amount: '1.75'
                  currency: USD
                spend_unknown_count: 0
                coverage:
                  listings_total: 3
                  listings_scanned: 3
                  pages_read: 1
                  complete: true
                  stopped_at_spend_floor: false
                  eligible: 3
                  excluded:
                    - reason: Pinned — always advertise
                      count: 1
                  skipped: 1
                  skipped_by_reason:
                    - code: rule_of_three
                      kind: guardrail
                      count: 1
                  unjudgeable: 0
                  unreadable: 0
                  listing_ids_not_scanned: []
                  search_terms: null
                notices:
                  - code: held_back
                    detail: >-
                      1 listing matched the rules but was held back by a
                      guardrail (rule of three: 1), with $12.00 of ad spend over
                      the period. `held_back` lists it with the reason.
                plan_hash: >-
                  e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
                fetched_at: '2026-10-17T12:00:00.000Z'
                source: live
        '400':
          $ref: '#/components/responses/Problem400'
        '401':
          $ref: '#/components/responses/Problem401'
        '402':
          $ref: '#/components/responses/Problem402'
        '403':
          $ref: '#/components/responses/Problem403'
        '404':
          description: Error. `not_found` carries `shop_id`.
          content:
            application/problem+json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Problem'
                  - type: object
                    properties:
                      shop_id:
                        description: The Etsy shop ID Alura read for.
                        type: string
        '405':
          $ref: '#/components/responses/Problem405'
        '409':
          description: >-
            Error. `etsy_not_logged_in` carries `shop_id`. `etsy_shop_mismatch`
            carries `shop_id`, `state`, `holder`, `last_served_at`, `action`.
            `holder_offline` carries `shop_id`, `state`, `holder`,
            `last_served_at`, `action`. `login_expired` carries `shop_id`,
            `state`, `holder`, `last_served_at`, `action`. `never_connected`
            carries `shop_id`, `state`, `holder`, `last_served_at`, `action`.
            `saved_shops_off` carries `shop_id`, `state`, `holder`,
            `last_served_at`, `action`. `etsy_refused` carries `shop_id`.
            `settings_unreadable` carries `version`.
          content:
            application/problem+json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Problem'
                  - type: object
                    properties:
                      shop_id:
                        description: The Etsy shop ID Alura read for.
                        type: string
                      state:
                        description: >-
                          The shop's live state, the same as GET
                          /v1/workspace/live shows for it.
                        type: string
                        enum:
                          - login_expired
                          - etsy_shop_mismatch
                          - holder_offline
                          - never_connected
                          - saved_shops_off
                      holder:
                        description: >-
                          The browser the state is about; null when none holds
                          the shop, or it is not known.
                        anyOf:
                          - type: object
                            properties:
                              label:
                                type: string
                                description: >-
                                  The browser's name, as Settings lists it
                                  ("Chrome on macOS · 64NN").
                              last_seen_at:
                                description: >-
                                  When it was last online (ISO 8601); null when
                                  unknown.
                                type:
                                  - string
                                  - 'null'
                            required:
                              - label
                              - last_seen_at
                            additionalProperties: false
                          - type: 'null'
                      last_served_at:
                        description: >-
                          When a browser last served this shop (ISO 8601); null
                          when none did.
                        type:
                          - string
                          - 'null'
                      action:
                        description: What fixes it, in one sentence for the seller.
                        type: string
                      version:
                        type: integer
                        minimum: 0
                        description: >-
                          The settings' version: 0 when none are saved, else
                          bumped by 1 on every save, the app's and the API's.
        '410':
          $ref: '#/components/responses/Problem410'
        '422':
          description: Error. `margin_required` carries `strategy_id`.
          content:
            application/problem+json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Problem'
                  - type: object
                    properties:
                      strategy_id:
                        type: string
                        description: The strategy that needs a margin.
        '429':
          description: >-
            Error. `etsy_rate_limited` carries `shop_id`, `retry_after_seconds`.
            `live_rate_limited` carries `shop_id`, `retry_after_seconds`.
          content:
            application/problem+json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Problem'
                  - type: object
                    properties:
                      shop_id:
                        description: The Etsy shop ID Alura read for.
                        type: string
                      retry_after_seconds:
                        type: integer
                        minimum: 1
                        description: >-
                          Seconds to wait before retrying, the same as the
                          Retry-After header.
        '500':
          $ref: '#/components/responses/Problem500'
        '502':
          description: Error. `etsy_changed` carries `shop_id`.
          content:
            application/problem+json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Problem'
                  - type: object
                    properties:
                      shop_id:
                        description: The Etsy shop ID Alura read for.
                        type: string
        '503':
          description: >-
            Error. `extension_offline` carries `shop_id`. `etsy_challenge`
            carries `shop_id`. `etsy_unavailable` carries `shop_id`, `reason`.
            `live_data_paused` carries `shop_id`.
          content:
            application/problem+json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Problem'
                  - type: object
                    properties:
                      shop_id:
                        description: The Etsy shop ID Alura read for.
                        type: string
                      reason:
                        description: >-
                          A saved shop's browser context was busy; retry after
                          Retry-After.
                        type: string
                        const: shop_busy
        '504':
          description: Error. `upstream_timeout` carries `shop_id`, `hint`.
          content:
            application/problem+json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Problem'
                  - type: object
                    properties:
                      shop_id:
                        description: The Etsy shop ID Alura read for.
                        type: string
                      hint:
                        description: >-
                          After an Etsy-side failure on `range=max`, read again:
                          a shorter range that is likelier to answer.
                        type: object
                        properties:
                          range:
                            type: string
                            const: last_30
                        required:
                          - range
                        additionalProperties: false
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X POST "https://api.alura.io/v1/workspace/ads/optimize/runs" \
              -H "Authorization: Bearer $ALURA_API_KEY" \
              -H "Content-Type: application/json" \
              -d '{"shop_id":"22841907","target":"listings"}'
        - lang: typescript
          label: TypeScript
          source: >-
            const res = await
            fetch('https://api.alura.io/v1/workspace/ads/optimize/runs', {
              method: 'POST',
              headers: {
                Authorization: `Bearer ${process.env.ALURA_API_KEY}`,
                'Content-Type': 'application/json',
              },
              body: JSON.stringify({
                "shop_id": "22841907",
                "target": "listings"
              }),
            });

            console.log(await res.json());
        - lang: python
          label: Python
          source: |-
            import json
            import os
            import urllib.request

            request = urllib.request.Request(
                "https://api.alura.io/v1/workspace/ads/optimize/runs",
                method="POST",
                data=json.dumps({
                  "shop_id": "22841907",
                  "target": "listings"
                }).encode(),
                headers={
                    "Authorization": f"Bearer {os.environ['ALURA_API_KEY']}",
                    "Content-Type": "application/json",
                },
            )
            with urllib.request.urlopen(request) as response:
                print(json.load(response))
components:
  headers:
    Request-Id:
      description: '`req_` + ULID; quote it when reporting a problem.'
      schema:
        type: string
    Alura-Credits-Cost:
      description: API credits this call cost.
      schema:
        type: integer
    Alura-Credits-Remaining:
      description: >-
        API credits left in the workspace's monthly allowance, counting calls
        still in flight. Absent when it cannot be read right now.
      schema:
        type: integer
  responses:
    Problem400:
      description: Error
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
          example:
            type: https://docs.alura.io/errors/invalid_request
            title: Invalid request
            status: 400
            code: invalid_request
            detail: Invalid request
            suggestion: Fix the request as the detail says, then send it again.
            retryable: false
            request_id: req_01JQ5W3H8M2N4P6R8T0V2X4Z6B
    Problem401:
      description: Error
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
          example:
            type: https://docs.alura.io/errors/unauthorized
            title: Unauthorized
            status: 401
            code: unauthorized
            detail: Unauthorized
            suggestion: 'Send a valid API key as `Authorization: Bearer alura_sk_...`.'
            retryable: false
            request_id: req_01JQ5W3H8M2N4P6R8T0V2X4Z6B
    Problem402:
      description: Error
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
          example:
            type: https://docs.alura.io/errors/credits_exhausted
            title: API credits exhausted
            status: 402
            code: credits_exhausted
            detail: API credits exhausted
            suggestion: Upgrade the plan or wait for the monthly reset.
            retryable: false
            request_id: req_01JQ5W3H8M2N4P6R8T0V2X4Z6B
    Problem403:
      description: Error
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
          example:
            type: https://docs.alura.io/errors/plan_required
            title: Plan required
            status: 403
            code: plan_required
            detail: Plan required
            suggestion: Upgrade the workspace plan to use this operation.
            retryable: false
            request_id: req_01JQ5W3H8M2N4P6R8T0V2X4Z6B
    Problem405:
      description: Error
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
          example:
            type: https://docs.alura.io/errors/method_not_allowed
            title: Method not allowed
            status: 405
            code: method_not_allowed
            detail: Method not allowed
            suggestion: Use one of the methods in the Allow header.
            retryable: false
            request_id: req_01JQ5W3H8M2N4P6R8T0V2X4Z6B
    Problem410:
      description: Error
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
          example:
            type: https://docs.alura.io/errors/listing_removed_on_etsy
            title: Listing removed on Etsy
            status: 410
            code: listing_removed_on_etsy
            detail: Listing removed on Etsy
            suggestion: >-
              The listing no longer exists on Etsy. Search the shop's listings
              again.
            retryable: false
            request_id: req_01JQ5W3H8M2N4P6R8T0V2X4Z6B
    Problem500:
      description: Error
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
          example:
            type: https://docs.alura.io/errors/internal_error
            title: Internal error
            status: 500
            code: internal_error
            detail: Internal error
            suggestion: Retry; if it keeps failing, report the request_id.
            retryable: true
            request_id: req_01JQ5W3H8M2N4P6R8T0V2X4Z6B
  schemas:
    Problem:
      type: object
      description: RFC 9457 problem details.
      properties:
        type:
          type: string
          format: uri
        title:
          type: string
        status:
          type: integer
        code:
          type: string
          description: A code from the error catalog; new codes may be added.
          x-extensible-enum:
            - invalid_request
            - unknown_parameter
            - invalid_cursor
            - cursor_window_exceeded
            - invalid_reference
            - id_type_mismatch
            - invalid_keyword
            - shop_id_required
            - listing_not_publishable
            - sales_window_not_covered
            - range_too_long_for_interval
            - target_not_available
            - unauthorized
            - credits_exhausted
            - plan_required
            - insufficient_scope
            - workspace_required
            - workspace_locked
            - your_shop_unavailable
            - writes_suspended
            - browser_refused
            - live_data_not_enabled
            - send_not_enabled
            - attachments_not_enabled
            - self_approval
            - role_required
            - impersonation_refused
            - recent_sign_in_required
            - etsy_scope_required
            - etsy_partner_required
            - not_found
            - not_collected
            - not_found_on_etsy
            - shop_opted_out
            - method_not_allowed
            - conflict
            - settings_conflict
            - settings_unreadable
            - optimize_settings_required
            - optimize_plan_changed
            - optimize_run_applied
            - optimize_run_applying
            - optimize_run_too_large
            - optimize_nothing_to_apply
            - optimize_nothing_to_revert
            - optimize_shop_busy
            - runs_unreadable
            - run_not_resumable
            - suggestion_not_pending
            - draft_sent
            - draft_dismissed
            - draft_sending
            - conversation_changed
            - key_limit_reached
            - etsy_not_logged_in
            - etsy_shop_mismatch
            - holder_offline
            - login_expired
            - never_connected
            - etsy_refused
            - extension_update_required
            - attachment_used
            - attachment_expired
            - attachment_unavailable
            - saved_shops_off
            - review_already_replied
            - insights_search_unavailable
            - reconnect_required
            - settings_not_fetched
            - listing_busy
            - settings_busy
            - shop_create_busy
            - idempotency_partial_unverifiable
            - listing_has_variations
            - listing_sold_out
            - changed_since
            - change_not_revertable
            - media_changed
            - text_changed
            - inventory_changed
            - base_unverifiable
            - listing_in_ab_test
            - activation_skipped
            - idempotency_processing
            - confirmation_required
            - test_shop_active_cap
            - write_outcome_unknown
            - margin_required
            - unprocessable
            - knowledge_limit_reached
            - status_required
            - listing_removed_on_etsy
            - optimize_run_expired
            - endpoint_removed
            - rate_limited
            - throttled
            - daily_credit_cap_exceeded
            - credits_reserved
            - fetch_limit_reached
            - write_rate_limited
            - sync_cooldown
            - shop_write_budget_exhausted
            - live_rate_limited
            - etsy_rate_limited
            - internal_error
            - write_misconfigured
            - etsy_changed
            - upstream_unavailable
            - extension_offline
            - etsy_unavailable
            - etsy_challenge
            - live_data_paused
            - live_data_unavailable
            - credits_unavailable
            - service_unavailable
            - fetch_unavailable
            - create_lock_unavailable
            - writes_paused
            - etsy_capacity
            - upstream_timeout
        detail:
          type: string
        suggestion:
          type: string
        retryable:
          type: boolean
        request_id:
          type: string
        upgrade_url:
          type: string
          format: uri
          description: 'credits_exhausted and plan_required: where to upgrade the plan.'
        credits_needed:
          type: integer
          description: 'API credit refusals: what the call needed.'
        credits_remaining:
          type: integer
          description: >-
            API credit refusals: what is left (of the month, or of the day for
            daily_credit_cap_exceeded).
        resets_at:
          type: string
          format: date-time
          description: >-
            credits_exhausted and daily_credit_cap_exceeded: when the limit
            resets.
      required:
        - type
        - title
        - status
        - code
        - detail
        - suggestion
        - retryable
        - request_id
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: 'An API key: `Authorization: Bearer alura_sk_...`.'

````

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