# Drop Indexes API

> Drop indexes by name on any database of the account with one system API of API Maker - a missing index is reported, not an error, so the call can run again.

Source: https://docs.apimaker.dev/v1/docs/apis-all/system-apis/system-generated-drop-indexes-api.html

Drops one or more indexes of a table by name, on any database, and reports what happened to each one. A name the table does not have is `NOT_FOUND`, not an error.

| | |
|---|---|
| Method | POST |
| URL | `/api/system-api/admin/drop-indexes` : `admin` is the user path of your account |
| Body | `{ instance, database, collection | table, indexes: [ names ], ifExists?, continueOnError? }` or an array of them |
| Answer | `data` : one result per name |
| From code | [`g.sys.system.dropIndexes`](https://docs.apimaker.dev/v1/examples/sys/system/dropIndexes.html) |

## The call

**Body**

```json
{
    "instance": "mysql8", "database": "inventory", "table": "orders",
    "indexes": [ "am_ix_orders_customer_id_status_3f9a1c", "old_idx_status" ],
    "ifExists": true,
    "continueOnError": true
}
```

| Property | Required | Meaning |
|---|---|---|
| `instance` | yes | Instance name, `crm::acme` for a tenant of a multi-tenant instance. |
| `database` | yes | Database name, as the account sees it. |
| `collection` or `table` | yes | The table. |
| `indexes` | yes | The names to drop. |
| `ifExists` | no, `true` | A name the table does not have is `NOT_FOUND`. `false` : it is `FAILED`. |
| `continueOnError` | no, `true` | A drop the database refuses is `FAILED` and the next ones go on. `false` : the call fails at the first one. |

## The answer

```json
{
    "success": true,
    "statusCode": 200,
    "data": [
        { "instance": "mysql8", "database": "inventory", "collection": "orders", "name": "am_ix_orders_customer_id_status_3f9a1c", "fields": [ "customer_id", "status" ], "status": "DROPPED" },
        { "instance": "mysql8", "database": "inventory", "collection": "orders", "name": "old_idx_status", "fields": [], "status": "NOT_FOUND", "message": "The index \"old_idx_status\" does not exist." }
    ]
}
```

- The `fields` of a dropped index are the ones it had. Every drop is logged in the index logs of Index Maker with its source.

## Access and settings

- Over HTTP, a system API answers once its [settings](https://docs.apimaker.dev/v1/docs/settings/systemApiSettings.html) give it `apiAccessType: TOKEN_ACCESS` (the token of an API user whose [group](https://docs.apimaker.dev/v1/docs/apis-security/api-group-permission.html) grants this system API, in `x-am-authorization`) or `IS_PUBLIC`. Without settings it is `NO_ACCESS` : your code calls it through `g.sys`, the admin panel tests it, and an HTTP call is refused.
- The settings can also cache the answer or require person tokens (`authProviders`) ; [pre and post hooks](https://docs.apimaker.dev/v1/docs/apis-all/hooks/preHook-api.html) run around it like around any API.
- The [request headers](https://docs.apimaker.dev/v1/docs/apis-all/header/requestHeader.html) apply : `x-am-response-case`, `x-am-content-type-response`, `x-am-internationalization`, `x-am-tenant-username`…

## Errors

| Code | When |
|---|---|
| `400` | The body is wrong : the message names the missing or invalid key. |
| `401` | No valid API user token, or the API is `NO_ACCESS` : `You are not authorized to access this API.` |
| `403` | No group grants this system API. |

## Related

- [All APIs at a glance](https://docs.apimaker.dev/v1/docs/apis-all/overview.html) · [Response format](https://docs.apimaker.dev/v1/docs/apis-all/response-format.html) · [System API settings](https://docs.apimaker.dev/v1/docs/settings/systemApiSettings.html) · [System APIs from code](https://docs.apimaker.dev/v1/examples/sys/system/system.html)
