# Styles

Map styles and their drafts. Every style carries a published version and a draft; Mapbox Studio edits the draft, and the three `draft` commands read and write it. A style's sprite sits at the same URLs but has [a command group of its own](https://docs.mapbox.com/ja/cli/reference/sprites/). Every command also takes the common flags — `--username`/`-u`, `--token`/`-t`, `--profile`, `--id` — described in [Shared parameters](https://docs.mapbox.com/ja/cli/reference/#shared-parameters).

-   [`mapbox styles list`](#mapbox-styles-list)
-   [`mapbox styles get`](#mapbox-styles-get)
-   [`mapbox styles create`](#mapbox-styles-create)
-   [`mapbox styles update`](#mapbox-styles-update)
-   [`mapbox styles delete`](#mapbox-styles-delete)
-   [`mapbox styles draft get`](#mapbox-styles-draft-get)
-   [`mapbox styles draft update`](#mapbox-styles-draft-update)
-   [`mapbox styles draft delete`](#mapbox-styles-draft-delete)

## `mapbox styles list`

Metadata for every style in an account.

**Parameters:**

| Parameter | Description |
| --- | --- |
| `--draft` | When present, includes draft styles in the listing. |
| `--start` | Style ID to use as a pagination cursor (exclusive). |
| `--limit` | Maximum number of styles to return. |
| `--deleted` | When `true`, returns recently deleted styles instead of active ones. |

**Examples:**

```sh
mapbox styles list
mapbox styles list --limit 5
```

## `mapbox styles get`

One style document, conforming to the Mapbox Style Specification.

**Parameters:**

| Parameter | Description |
| --- | --- |
| `<style-id>` | Unique identifier for the style. |
| `--download` | When present, returns the style as a downloadable JSON file attachment. |
| `--optimize` | When `true`, rewrites vector source URLs for cache optimization. |

**Examples:**

```sh
mapbox styles get ckstyle00000000000000001a
mapbox styles get ckstyle00000000000000001a -o json > style.json
```

## `mapbox styles create`

Adds a new style. The server fills in `created`, `id`, `modified`, `owner` and the sprite URL; `name` defaults to the style ID if the body omits it.

**Parameters:**

| Parameter | Description |
| --- | --- |
| `--data`/`-d` | Request body as JSON string |

**Examples:**

```sh
mapbox styles create \
  -d '{"name":"My Style","version":8,"sources":{},"layers":[]}'
```

## `mapbox styles update`

Modifies an existing style. The body needs `name`, and must not carry `created` or `modified`. A cross-version update — v7 to v8 — fails.

**Parameters:**

| Parameter | Description |
| --- | --- |
| `<style-id>` | Unique identifier for the style. |
| `--data`/`-d` | Request body as JSON string |

**Examples:**

```sh
mapbox styles update ckstyle00000000000000004d \
  -d '{"name":"Renamed","version":8,"sources":{},"layers":[]}'
```

## `mapbox styles delete`

Removes a style and its sprites. Mapbox keeps a deleted style recoverable for 30 days, but the CLI has no command to bring one back.

**Parameters:**

| Parameter | Description |
| --- | --- |
| `<style-id>` | Unique identifier for the style. |

**Examples:**

```sh
mapbox styles delete ckstyle00000000000000003c
```

## `mapbox styles draft get`

The draft version of a style. With no draft, the published style comes back instead — which is also how you can tell a draft was discarded.

**Parameters:**

| Parameter | Description |
| --- | --- |
| `<style-id>` | Unique identifier for the style. |

**Examples:**

```sh
mapbox styles draft get ckstyle00000000000000004d
```

## `mapbox styles draft update`

Updates the draft, creating one from the published version if none exists. The published style stays as it was until Studio publishes the draft.

**Parameters:**

| Parameter | Description |
| --- | --- |
| `<style-id>` | Unique identifier for the style. |
| `--data`/`-d` | Request body as JSON string |

**Examples:**

```sh
mapbox styles draft update ckstyle00000000000000004d \
  -d '{"name":"Work in progress","version":8,"sources":{},"layers":[]}'
```

## `mapbox styles draft delete`

Discards the draft, reverting the style to its published version.

**Parameters:**

| Parameter | Description |
| --- | --- |
| `<style-id>` | Unique identifier for the style. |

**Examples:**

```sh
mapbox styles draft delete ckstyle00000000000000004d
```