# Delete a port

`DELETE https://app.skylit.ai/api/nexus/v1/trading/ports/{id}`

API: Nexus.

Delete one of your extra ports, the same delete as in Nexus. It leaves your list and its id stops working everywhere: an order or a read that sends it answers `404 port_not_found`. Its trades stay saved: no list, journal or stats read shows them after this, but a trade read by its own id (`GET /api/nexus/v1/trades/{id}`) still answers. You can't undo it. It frees a spot and its name.

Main and Bot always stay, and so does your ranked port. A port with an open trade or a working order can't be deleted: close and cancel first, nothing is closed for you. No body. It counts as a write.

A retry after it worked answers `404 port_not_found`: if you lost the answer, list your ports.

## Authentication

Send your Skylit API key as a bearer token: `Authorization: Bearer <key>`. No other header is accepted.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes | The port's id, from the list. |

## Example request

```bash
curl "https://app.skylit.ai/api/nexus/v1/trading/ports/9e8d7c6b-5a4f-4e3d-a2c1-0b9a8f7e6d03" \
  -H "Authorization: Bearer $SKYLIT_API_KEY"
```

## Responses

### 200

The port is deleted.

Swing, deleted.:

```json
{
  "data": {
    "id": "9e8d7c6b-5a4f-4e3d-a2c1-0b9a8f7e6d03",
    "deleted": true
  }
}
```

### 401

No key, or a key that isn't valid. Codes: `missing_api_key`, `invalid_api_key`.

No key sent.:

```json
{
  "error": {
    "code": "missing_api_key",
    "message": "Send your Skylit API key in the Authorization header: Authorization: Bearer YOUR_SKYLIT_API_KEY."
  }
}
```

### 403

The key works but this can't be done. Codes: `feature_disabled` (ports are switched off on the server: leave `port` out), `account_suspended`, `nexus_access_denied`.

Ports are switched off on the server.:

```json
{
  "error": {
    "code": "feature_disabled",
    "message": "Ports aren't open to members yet."
  }
}
```

### 404

Code: `port_not_found`. No live port with that id on your account. Someone else's port answers the same.

Not one of your ports.:

```json
{
  "error": {
    "code": "port_not_found",
    "message": "No port with that id on your account."
  }
}
```

### 409

The port stays and nothing changed. Codes: `open_positions` (an open trade or a working order is on it: close and cancel first), `cannot_delete_default` (Main and Bot stay), `cannot_delete_ranked` (your ranked port stays), `cannot_delete_ranked_agent` (the port is your ranked agent: make another account your ranked agent in Nexus first).

Something is still open on it.:

```json
{
  "error": {
    "code": "open_positions",
    "message": "Close this port's open trades and cancel its orders first."
  }
}
```

Main and Bot can't be deleted.:

```json
{
  "error": {
    "code": "cannot_delete_default",
    "message": "Main and Bot are your own accounts, so they can't be deleted."
  }
}
```

### 429

Over a rate limit. Wait `Retry-After` seconds, then retry. Codes: `rate_limited`, and `stream_limit_reached` (too many live streams open: 3 per key, 6 per account).

Headers: `Retry-After`, `X-RateLimit-Limit`, `X-RateLimit-Remaining`.

Too many writes from this key.:

```json
{
  "error": {
    "code": "rate_limited",
    "message": "Too many requests (limit 30). Slow down and retry in 12 seconds."
  }
}
```

### 500

Something went wrong on our side. If you sent a `clientOrderId`, retry with the same one. Code: `internal_error`.

Retry with the same clientOrderId.:

```json
{
  "error": {
    "code": "internal_error",
    "message": "Something went wrong on our side. If you sent a clientOrderId, retry with the same one (it can't fill twice). Otherwise check your account before retrying."
  }
}
```
