POST /v1/indexes/products/swap-with 🔒 Bearer

Swap with another index

Atomic alias swap — the cutover step of the zero-downtime reindex pattern.

Repoints the source index's alias at the target index's documents in a single atomic operation. After this returns, search traffic against the source name sees the target's data. The displaced data is preserved (still reachable via the target name) unless you pass drop_source_after: true.

This is the cutover step of zero-downtime reindex. You build the temp index with fresh data, copy the settings, then call this — live search never sees an empty index.

# Path parameters

Name Type Description
name string The live / source index. Its alias is what gets repointed.

# Body parameters

Name Type Required Description
target_index string required The temp index holding the new data.
drop_source_after bool optional, default false When true, the displaced documents (and the temp index row) are deleted after the swap. Saves storage; gives up rollback.

# Response

{
  "data": {
    "swapped": true,
    "source": "products",
    "target": null,
    "source_collection_now": "t_a1b2c3_products_tmp_v1",
    "previous_collection_deleted": true
  }
}

target is null when drop_source_after is true — the temp index is gone. Otherwise it's the name the displaced documents now live under (useful if you need to roll back).

# Rollback

If you didn't pass drop_source_after, rolling back is one more swap:

curl -X POST https://api.skryx.io/v1/indexes/products/swap-with \
  -H "Authorization: Bearer $SKRYX_API_KEY" \
  -d '{ "target_index": "products_tmp" }'

This swaps back to the previous data. The two indexes alternate.

# Errors

Status Code Reason
404 SK-SE-404 One of the indexes does not exist.
400 SK-SE-400 Attempting to swap an index with itself.
esc
POST /v1/indexes/products/swap-with