# Pro Import API

# Description

The Pro Import API allows you to manage your Blocket ads programmatically. This document describes how to create, update and delete ads, by invoking a REST API. It also describes how to get information about the state of your ads.

The Pro Import API should only be used for managing ads on Blocket and Bytbil, not for powering websites or similar. API users must keep a record of ads in their own system. Any changes made directly in Blocket Admin will not be reflected when retrieving the ad via the API. The API only exposes data that was created or updated through the API itself. For consistency and data integrity, all ad modifications should preferably be performed via the API.

Are you migrating from legacy file imports? Pay attention to the [chapter on migration](#migration-from-file-imports-via-ftp).

For recent changes and new features, see the [Changelog](changelog).

# Caveats

* By using the API, you cannot publish ads outside registered vehicles manually and pay by invoice.
* Ad body doesn't support certain characters — these will be replaced by "-". Currently the affected characters are: "<", ">".
* Terminology about *dealers* and *dealer\_groups* originates from mobility customers, but applies to other types of customers too.
* Not all category specific fields are yet supported.

# OpenAPI documentation

The API documentation is available at the following URLs:

| Service | URL |
| :---- | :---- |
| Swagger | [https://api.blocket.se/pro-import-api/docs/swagger-ui/](https://api.blocket.se/pro-import-api/docs/swagger-ui/) |
| ReDoc | [https://api.blocket.se/pro-import-api/docs/redoc/](https://api.blocket.se/pro-import-api/docs/redoc/) |

# Testing

There is no separate test environment. All API integrations must be developed and tested directly in the **production environment**.

To avoid publishing test ads on the marketplaces, you can set `visible: false` when creating ads. These ads will:

* Not be published on any marketplaces
* Be accessible only within **Blocket Admin** and the **API**
* **Not incur any charges**, as they are not publicly listed on the marketplaces

There is also a `/v4/{vehicle_type}/validate` endpoint that can be used to validate input data without saving anything.

# The workflow

The API allows you to create, update, renew and delete ads. After making a request it will be processed asynchronously, and you will be able to check the progress and result by looking at the action logs associated with the ad, and the final state of the ad.

The common procedure to create an ad is as follows:

1. Submit an ad by performing an HTTP POST to the API with all the ad data.
2. Perform an HTTP GET to the API to check the status of the ad creation.

If everything went well, the response from the HTTP GET will contain info on all state transitions performed during the workflow execution (`logs` field), as well as a Blocket ad ID (`blocket_ad_id`) for the newly created Blocket ad and Bytbil ad ID (`offer_id`) for registered vehicles.

> **Important:** The `blocket_ad_id` field is assigned asynchronously after the ad has been published on Blocket. It will be `null` immediately after POST — this is expected behavior. Poll via `GET /v4/ad/{source_id}` until the log shows `publish | done` and `blocket_ad_id` is populated. Typical latency is seconds to minutes depending on current load. An ad that takes over a listing the dealer already has gets the listing's `blocket_ad_id` when the takeover finishes, also with `visible: false`.

All **actions** made on the ad while processing it will have their own state. By inspecting the ad logs you can track each action and its state. All actions start with the state processing and transition into done when completed. If there was an error while processing, the action will end up in state error.

The ad itself will have a **state** indicating if the ad was created or deleted. While this means that the ad was successfully created in the API, there could be more information in the ad logs which could indicate that there was an issue with a specific action.

##### **Ad actions**

| Name | Type | Description |
| :---- | :---- | :---- |
| `create` | string | Action for creating the ad within the API |
| `update` | string | Action for updating the ad |
| `bump` | string | Action for renewing the ad on marketplaces |
| `boost` | string | Action for activating Pole Position on the ad |
| `handle_media` | string | Action for handling media on the ad (uploading images, removing previous images etc) |
| `publish` | string | Action for publishing the ad on marketplaces |
| `delete` | string | Action for removing the ad |
| `unpublish` | string | Action for unpublishing the ad on marketplaces |

##### **Ad log states**

| Name | Type | Description |
| :---- | :---- | :---- |
| `processing` | string | Ad action is being processed |
| `done` | string | Ad action completed successfully |
| `error` | string | There were error(s) while processing the action |

##### **Log entry structure**

Each entry in the `log` array has the following fields:

| Field | Type | Description |
| :---- | :---- | :---- |
| `request_id` | string (UUID) | Groups all actions performed during a single API request |
| `created` | string (ISO 8601) | Timestamp when the log entry was created |
| `action` | string | One of the ad actions listed above (e.g. `create`, `publish`) |
| `state` | string | One of `processing`, `done`, or `error` |
| `external_message` | string / object | Human-readable status message or error details |

Example value (after a successful create + publish flow):

```json
[
  {"request_id": "a1b2c3d4-...", "created": "2025-01-15T10:00:00Z", "action": "create",       "state": "processing", "external_message": "Processing"},
  {"request_id": "a1b2c3d4-...", "created": "2025-01-15T10:00:00Z", "action": "create",       "state": "done",       "external_message": "Ad created"},
  {"request_id": "a1b2c3d4-...", "created": "2025-01-15T10:00:01Z", "action": "handle_media",  "state": "processing", "external_message": "Processing"},
  {"request_id": "a1b2c3d4-...", "created": "2025-01-15T10:00:02Z", "action": "handle_media",  "state": "done",       "external_message": "Images uploaded"},
  {"request_id": "a1b2c3d4-...", "created": "2025-01-15T10:00:03Z", "action": "publish",       "state": "processing", "external_message": "Publishing in progress."},
  {"request_id": "a1b2c3d4-...", "created": "2025-01-15T10:00:05Z", "action": "publish",       "state": "done",       "external_message": "Ad published"}
]
```

> **Tip:** To check if an ad has been fully published, poll `GET /v4/{vehicle_type}/{source_id}` and look for a log entry with `action: publish` and `state: done`. The `request_id` field lets you correlate which actions belong to the same API call. For ads with a long action history, use `GET /v4/ad/{source_id}/log?request_id={request_id}` to retrieve only the log entries for a specific request.

**Ad states**

| Name | Type | Description |
| :---- | :---- | :---- |
| `created` | string | Ad is created. Note: the ad may not be visible on the marketplace if `visible=false` is set or a marketplace error occurred — check log messages for details. |
| `deleted` | string | Ad is deleted (soft delete — the ad is unpublished from all marketplaces but remains retrievable via GET) |

> **Note:** The `state` field is updated asynchronously by the background worker. After a `DELETE` request, the state will remain `created` until the worker has finished processing. Poll via `GET` and check for a log entry with `action: delete` and `state: done` — at that point the ad's state will be `deleted`. See the DELETE endpoint section for details.
>
> Deletion is a soft delete. The ad is unpublished from all marketplaces, but the ad data is retained in the API and can still be retrieved via `GET /v4/ad/{source_id}` or `GET /v4/{vehicle_type}/{source_id}`.

# Authentication

All invocations to the API require a JWT token sent as a `X-Auth-Token` request header. You can get one from customer support by contacting [butikssupport@blocket.se](mailto:butikssupport@blocket.se). The token contains one of two scope types:

* `dealer_code` — Grants access to a single dealer. The `dealer_code` field can be omitted from the request body — it is inferred from the token.
* `dealer_group` — Grants access to all dealers within a group. A dealer group contains one or more dealer codes. When creating an ad (`POST`), you **must** include `dealer_code` in the request body to specify which dealer the ad belongs to. For updates and deletes, the `dealer_code` is read from the existing ad.

# Error Responses

## HTTP Status Codes

| Status | Meaning | When |
| :---- | :---- | :---- |
| `200` | OK | GET, PUT, PATCH, DELETE succeeded |
| `201` | Created | POST succeeded — ad created and queued for processing |
| `400` | Bad Request | Validation error — see error format below |
| `401` | Unauthorized | Missing or invalid `X-Auth-Token` header |
| `403` | Forbidden | Token is valid but lacks required scope for the endpoint |
| `404` | Not Found | Ad with the given `source_id` does not exist or does not belong to your dealer |

## Error Format

When a request fails validation, the API returns HTTP 400 with a JSON object. Each key is a field name, and each value is an array of error messages for that field:

```json
{
  "title": ["This field is required."],
  "contact": ["This field is required."]
}
```

Nested field errors (e.g. `category_fields`) include the full path:

```json
{
  "category_fields": {
    "registration_number": ["This field is required."],
    "brand": ["\"invalid_brand\" is not a valid choice."]
  }
}
```

Non-field errors (e.g. business logic violations) use a string array under a single key:

```json
["Ad has been deleted, cannot update"]
```

Authentication errors (401) return:

```json
{"detail": "Invalid token: <error details>"}
```

# API Versions

* **V5** (`/v5/{vehicle_type}/`) — Latest version, recommended for new integrations. On the eight registered vehicle types it uses new values for body type, drive type, fuel and a few brands; the key change is that `powertrain.fuel` (singular string) replaces `powertrain.fuels` (array). On those eight, an existing V3 or V4 ad can be read and deleted through V5 but must be migrated before it can be updated — see [Migrating V3/V4 ads to V5](#migrating-v3v4-ads-to-v5). Boats, agriculture, bus, truck and construction are served by V5 too, on the same schema V4 uses, so ads in those categories can be created and updated through V5 with no migration at all. See the [Changelog](changelog) for full details.
* **V4** (`/v4/{vehicle_type}/`) — Supports all vehicle categories. Trailer is the only vehicle type with no V5 endpoint: existing trailer ads stay on V4, and new ones cannot be created.
* **V3** (`/v3/ad`) — Legacy version. New features are V4/V5-only.

API base URL V3: **https://api.blocket.se/pro-import-api/v3/**

API base URL V4: **https://api.blocket.se/pro-import-api/v4/**

API base URL V5: **https://api.blocket.se/pro-import-api/v5/**

# Renewal and promotion

It is possible to **renew** a Blocket ad. This invocation is asynchronous and requires no JSON body. A renewal of an ad will make it appear as new — first in the listing (charges apply).

* `GET /v4/ad/{source_id}/bump`
  initiates a renewal of a Blocket ad

For registered vehicles, you can choose to exclude either Blocket or Bytbil by passing `exclude_bytbil=true` or `exclude_blocket=true`.

It is also possible to activate **Pole Position** on an ad. This will make the ad appear first in the search result. If several ads with Pole Position match the end user's search filter, only one is shown. Pole Position lasts for 3 days. Charges apply.

* `GET /v4/ad/{source_id}/pole_position`
  activates Pole Position on an ad

**Prerequisites:** The ad must be visible (`visible=true`). Pole Position is only available for registered vehicle categories (Blocket only).

# Endpoints

> **Note:** All generic `/v4/ad/` endpoints (GET, DELETE, bump, pole_position, retry) are also available on the typed endpoints (`/v4/{vehicle_type}/`). For POST, PUT and PATCH you **must** use the typed endpoints.

The POST, PUT, PATCH and DELETE API invocations are asynchronous. This means you will get a prompt response, but the operation will be executed afterwards. The only synchronous operation is the GET invocation (except /bump and /pole_position).

### POST /v4/{vehicle_type} — Create an ad {#post-/ad---create-an-ad}

Use this endpoint to create an ad. The creation will happen asynchronously and you will need to check the status/result of the operation with a GET request.

Refer to the [OpenAPI documentation](#openapi-documentation) for more detailed information about all fields.

#### Ad fields

| Name | Type | In | Required | Description |
| :---- | :---- | :---- | :---- | :---- |
| `id` | string (UUID) | Response | — | Internal ad ID. Ads are addressed by `source_id`; `id` is only accepted as a list filter. |
| `source_id` | string | Both | Yes | Client's reference ID. See `source_id` section. |
| `dealer_code` | string | Both | Depends | The dealer\_code for which to create the ad. Required if auth scope is `dealer_group`, not needed if auth scope is `dealer_code`. |
| `category_id` | int | Both | Yes | See `category_id` section |
| `state` | string | Response | — | Ad state: `created` or `deleted`. Updated asynchronously — see Ad States section. |
| `title` | string | Both | Depends | Ad title. **Required** for: boat, truck, bus, construction, and agriculture categories. **Must not be sent** for: car, transport, motorcycle, moped, snowmobile, ATV, camper, caravan, and trailer — the title is generated automatically, and including it will return a `400` error. |
| `body` | string | Both | No | Ad body text |
| `visible` | boolean | Both | No | `Default=true`. Set to `false` to prevent the ad from being published on marketplaces. |
| `price` | array of objects | Both | No | See `price` section |
| `image_urls` | array of strings | Request | No | See `image_urls` section |
| `image_refs` | array of objects | Response | — | Processed image references. Each object contains `url` (original URL), `cdn_url` (CDN URL where the image is served), `id` (internal image reference ID), and `checksum`. |
| `url` | string | Both | No | URL to page at the seller's website with more info about the ad. |
| `video_url` | string | Both | No | URL to Youtube or Vimeo video that is shown on the ad page. |
| `location` | object | Both | No | See `location` section. |
| `contact` | object | Both | Depends | See `contact` section. **Required** for: boat, truck, bus, construction, and agriculture categories. **Must not be sent** for: car, transport, motorcycle, moped, snowmobile, ATV, camper, caravan, and trailer — including it will return a `400` error. |
| `category_fields` | object | Both | Yes | Vehicle-specific attributes (e.g. `registration_number`, `brand`, `fuel`, `mileage`). These fields are displayed on the ad page on blocket.se and enable filtering in search results. The available fields vary by vehicle type — see the [Category Reference](category-reference) or the [Swagger UI](https://api.blocket.se/pro-import-api/docs/swagger-ui/) for full field specifications per category. |
| `dont_publish_on_failed_images` | boolean | Both | No | `Default=false`. Set to true if you don't want to publish the ad if any of the images have an error. |
| `product_declaration` | string | Both | No | URL to a hosted "varudeklaration" in PDF format. |
| `blocket_ad_id` | string | Response | — | Blocket marketplace ad ID. Assigned asynchronously after publish. |
| `offer_id` | string | Response | — | Ad identifier on Bytbil. Only present for registered vehicle categories. |
| `api_version` | string | Response | — | API version whose schema last wrote the ad (`v3`, `v4` or `v5`). On V5, read it before `category_fields` — see [Reading V3/V4 ads through V5](#reading-v3v4-ads-through-v5) |
| `created` | string (ISO 8601) | Response | — | Timestamp when the ad was created |
| `updated` | string (ISO 8601) | Response | — | Timestamp when the ad was last updated |
| `log` | array of objects | Response | — | Action log entries (when included via query parameter). See Action Log section. |

##### `source_id`

Your ID for the ad. Each ad must have a unique `source_id`, since it is used to create, update, get and delete the ad.
We recommend using a UUID here to ensure uniqueness.

> **Important:** Once a `source_id` has been used for a dealer, it cannot be reused — even after the ad is deleted. This is because deleted ads are retained in the system (soft delete). Use UUIDs to avoid collisions.

##### `category_id`

| ID | Path / Name | API version |
| :---- | :---- | :---: |
| `1020` | Vehicles > Cars | V3, V4, V5 |
| `1021` | Vehicles > Vans | V3, V4, V5 |
| `1045` | Vehicles > Trailer | V3, V4 (create disabled — update/delete only) |
| `1060` | Vehicles > Boats | V4 |
| `1063` | Vehicles > Boats > Inflatable / RIB Boat | V3 |
| `1064` | Vehicles > Boats > Dinghy / Rowboat | V3 |
| `1065` | Vehicles > Boats > Kayak / Canoe | V3 |
| `1066` | Vehicles > Boats > Jet Ski | V3 |
| `1067` | Vehicles > Boats > Other | V3 |
| `1101` | Vehicles > Caravan | V3, V4, V5 |
| `1102` | Vehicles > Motorhome | V3, V4, V5 |
| `1121` | Vehicles > Mopeds & A-Tractors > Mopeds | V3, V4, V5 |
| `1122` | Vehicles > Mopeds & A-Tractors > A-Tractors | V3, V4 |
| `1140` | Vehicles > Motorcycle | V3, V4, V5 |
| `1143` | Vehicles > ATV | V3, V4, V5 |
| `1180` | Vehicles > Snowmobile | V3, V4, V5 |
| `1221` | Vehicles > Trucks, Machinery & Construction > Truck & Bus | V3 |
| `1222` | Vehicles > Forestry & Agricultural Machinery > Agricultural Machinery | V3 |
| `1223` | Vehicles > Trucks, Machinery & Construction > Construction Machinery | V3 |
| `1224` | Vehicles > Trucks, Machinery & Construction > Truck & Material Handling | V3 |
| `1225` | Vehicles > Forestry & Agricultural Machinery > Forestry Machinery | V3 |
| `1226` | Vehicles > Forestry & Agricultural Machinery > Ground Care Machinery | V3 |
| `1227` | Vehicles > Forestry & Agricultural Machinery > Agriculture Thresher | V4 |
| `1228` | Vehicles > Forestry & Agricultural Machinery > Agriculture Tractor | V4 |
| `1229` | Vehicles > Forestry & Agricultural Machinery > Agriculture Tools | V4 |
| `1321` | Vehicles > Trucks, Machinery & Construction > Bus | V4 |
| `1322` | Vehicles > Trucks, Machinery & Construction > Truck | V4 |
| `1323` | Vehicles > Trucks, Machinery & Construction > Construction | V4 |

For V4-only categories, see the [Category Reference](category-reference) for full field specifications and examples.

##### `price`

Array of objects representing prices for the ad. For registered vehicles, you can also send in price as leasing. Please see the [OpenAPI documentation](#openapi-documentation) for details.

| Type | Description |
| :---- | :---- |
| `list` | Regular list price |
| `reduced` | Reduced/sale price (not allowed when creating an ad with POST; allowed on PUT/PATCH and on `POST /v5/{vehicle_type}/{source_id}/migrate`) |
| `leasing` | Leasing price (only supported by registered vehicle categories) |

Example value:

```json
[{"type": "list", "amount": 7000, "currency": "SEK"}]
```

##### `image_urls`

Array of strings containing URLs to images for the ad. Accepted formats are JPG and PNG. The sort order of the images is the order of the list. Every time you want to update images, you need to send the complete list and it will replace the previous list. Already uploaded images that match an existing checksum will be internally reused.

Example value:

```json
[
    "https://cdn.example.com/image1.jpg",
    "https://cdn.example.com/image2.jpg"
]
```

##### `location`

Object with location parameters. If omitted or set to `null`, the ad's location defaults to your dealer's address configured in Blocket Admin. The API response will show `location: null` but the published ad will use the dealer's location.

There are three alternatives for setting ad location:

| Parameter name | Type | Required | Description |
| :---- | :---- | :---- | :---- |
| `latitude` + `longitude` | string | No | Decimal coordinates. Both must be provided together. Works for all categories. |
| `zipcode` | string | No | Zip/postal code without spaces. Works for all categories. |
| `lkf` | string | No | Swedish area code (LKF). See `lkf` section. Only works for non-registered vehicle categories (boats, agriculture, etc.). Not supported for registered vehicles (car, motorcycle, etc.). |

Example value:

```json
{"latitude": 59.53485752244251, "longitude": 16.71093897174057}
```

###### `lkf`

LKF is a Swedish abbreviation for "län, kommun, församling" (region, municipality, parish), and is a four or six digit area code (LK vs full LKF). Either the four or six digit version of the LKF can be used, where the latter increases location accuracy further and is particularly relevant to increase accuracy for ads located in Stockholm, Göteborg and Malmö. For example, the LK and full LKF for Vaksala in the city of Uppsala is:

`LK code: 0380`
`LKF code: 038004`

Where the LK code 0380 refers to the greater Uppsala-area and the six digit LKF code 038004 refers to Vaksala specifically. A complete list of LKF codes can be found [here](https://www.scb.se/contentassets/13ec5841d80045498d960d456e87ea78/fors2020_justerad.xls).

Please note that Blocket does not show exact coordinates, but resolves to a predefined geographical area.

##### `contact`

Object with contact information. Will override store information. **Required** for: boat, truck, bus, construction, and agriculture categories. **Must not be sent** for: car, transport, motorcycle, moped, snowmobile, ATV, camper, caravan, and trailer — including it will return a `400` error.

| Parameter name | Type | Required | Description |
| :---- | :---- | :---- | :---- |
| `name` | string | No | Seller's name |
| `phone` | string | No | Phone number (digits only, optionally prefixed with `+`, 8–16 characters) |
| `email` | string | Yes | Email address |

Example value:

```json
{"name": "Sir Henry Williamsworth III", "phone": "0700000000", "email": "email@example.com"}
```

##### `category_fields`

Every vehicle type has its own set of `category_fields` that describe the vehicle's attributes — for example `registration_number`, `brand`, `model`, `fuel`, `mileage` and `body_type` for cars, or `brand`, `model_year`, `powertrain`, `physics` and `equipments` for boats. These fields are required when creating a V4 ad and are what makes the ad searchable and filterable on blocket.se.

Creating an ad for a registered vehicle without `category_fields` is rejected with a `400` error: on V3, V4 and V5 for a car, transport vehicle, motorcycle, ATV or snowmobile, and on V4 and V5 also for a moped, camper or caravan.

The available fields vary by vehicle type. See the [Category Reference](category-reference) for full field specifications and examples per category.

> **Tip:** For the most up-to-date field definitions and valid enum values, open `POST /v4/{vehicle_type}` (e.g. `POST /v4/car`) in the [Swagger UI](https://api.blocket.se/pro-import-api/docs/swagger-ui/) and click the **Schema** tab next to "Example Value". This shows exact field names, types, required/optional status and all accepted values for each category.

### GET /v4/ad — List ads

Use this endpoint to list your ad-requests and see progress/result of previous POST/PUT/DELETE operations. Each POST/PUT/DELETE on a certain `source_id` will appear as an individual entry. Log messages can be included with the help of the `include` field but only the last 100 messages will be provided. To get older log messages — see the endpoint for getting ad logs.

#### Parameters

| Name | Type | Description |
| :---- | :---- | :---- |
| `id` | Filter | Internal ad ID (UUID). The only place `id` is accepted; ads are addressed by `source_id`. |
| `state` | Filter | Values available: `created`, `deleted` |
| `source_id` | Filter | Client's reference ID (exact match) |
| `source_id__in` | Filter | Comma separated list of source IDs to include |
| `source_id__icontains` | Filter | Case-insensitive partial match on source ID |
| `dealer_code` | Filter | Customer identifier |
| `category_id` | Filter | Category ID (exact match) |
| `category_id__in` | Filter | Comma separated list of category IDs to include |
| `search` | Filter | Case-insensitive text search across the `title` and `body` fields |
| `blocket_ad_id` | Filter | Ad ID on Blocket |
| `blocket_ad_id__in` | Filter | Comma separated list of Blocket ad IDs to include |
| `registration_number` | Filter | Registration number of the vehicle (case-insensitive). Only works for registered vehicles. |
| `created__gt` | Filter | Format: `YYYY-MM-DD HH:MM:SS` |
| `created__gte` | Filter | Format: `YYYY-MM-DD HH:MM:SS` |
| `created__lt` | Filter | Format: `YYYY-MM-DD HH:MM:SS` |
| `created__lte` | Filter | Format: `YYYY-MM-DD HH:MM:SS` |
| `updated__gt` | Filter | Format: `YYYY-MM-DD HH:MM:SS` |
| `updated__gte` | Filter | Format: `YYYY-MM-DD HH:MM:SS` |
| `updated__lt` | Filter | Format: `YYYY-MM-DD HH:MM:SS` |
| `updated__lte` | Filter | Format: `YYYY-MM-DD HH:MM:SS` |
| `limit` | Setting | Limit results |
| `offset` | Setting | Offset results |
| `ordering` | Setting | Values available: `-created`, `created`, `-updated`, `updated`, `-source_id`, `source_id` |
| `fields` | Setting | Comma separated fields to include in response |
| `include` | Setting | Comma separated fields to include other than the defaults. Fields excluded by default in this endpoint are: `log.` **Note: only the 100 latest log messages are included.** To view more messages use `/v4/ad/{source_id}/log` endpoint. |

#### Example requests

```
GET /v4/ad?state=deleted
GET /v4/boat?state=created&ordering=-created&limit=10
GET /v4/ad?source_id__in=uuid-1,uuid-2,uuid-3&include=log
GET /v4/car?created__gte=2025-01-01 00:00:00&ordering=-created
```

### GET /v4/ad/{source_id}

Look up a specific ad based on source ID. Only includes the last 100 log messages.

### GET /v4/ad/{source_id}/log

Look up all log messages for an ad. This endpoint provides a paginated list of all log messages for an ad.

#### Parameters

| Name | Type | Description |
| :---- | :---- | :---- |
| `action` | Filter | Values available: create update bump boost delete handle\_media publish unpublish |
| `state` | Filter | Values available: processing done error |
| `request_id` | Filter | Filter by request ID (UUID) to see only log entries from a specific API call |
| `limit` | Setting | Limit results |
| `offset` | Setting | Offset results |
| `ordering` | Setting | Values available: -created created |

### PUT /v4/{vehicle_type}/{source_id} — Update an ad

Use this endpoint to update an ad. Same signature as ad creation except for `source_id` which is provided in the path instead of the body. The ads contents will be updated but it will not appear as new. To renew an ad — see `/v4/ad/{source_id}/bump` endpoint.

> **Important — merge semantics:** Both PUT and PATCH use **deep merge** semantics. This differs from the HTTP standard where PUT replaces the entire resource. In this API, fields not included in the request body are **preserved**, not cleared. Nested objects such as `category_fields` are also merged recursively.
>
> This means PUT and PATCH are functionally equivalent — both perform a partial update. To clear a field, explicitly set it to `null` (for nullable fields).

You can use the PUT method to revive a deleted ad in unregistered vehicle categories (excluding registered vehicles such as cars and vans).

### PATCH /v4/{vehicle_type}/{source_id} — Update part of an ad

Use this endpoint to update part of an ad. Same signature as ad creation except for `source_id` which is provided in the path instead of the body. The ads contents will be updated but it will not appear as new. To renew an ad — see `/v4/ad/{source_id}/bump` endpoint.

> **Note:** PATCH uses the same deep merge behavior as PUT — see the PUT section above for details.

You can use the PATCH method to revive a deleted ad in unregistered vehicle categories (excluding registered vehicles such as cars and vans).

### DELETE /v4/ad/{source_id} — Delete an ad

Request to delete an ad. Like all write operations, deletion is **asynchronous** — the endpoint returns immediately while the actual deletion is processed in the background.

The response returns the ad with `state: "created"`. This is expected. The state transitions to `"deleted"` once the background worker has unpublished the ad from all marketplaces. To confirm deletion, poll `GET /v4/ad/{source_id}` and look for a log entry with `action: delete` and `state: done`.

### GET /v4/ad/{source_id}/bump — Renew an ad

Calling this endpoint will make the ad appear as new again. Charges apply.

**Prerequisites:** The ad must be visible (`visible=true`) and published (a bump on an ad whose create failed returns `400`). The dealer must have bump permissions for at least one marketplace, and for ads without an `offer_id` that marketplace must be Blocket.

### GET /v4/ad/{source_id}/pole_position — Set pole position on an ad

Calling this endpoint will make the ad appear first in the search result. If several ads with pole position match the end user's search filter, only one is shown. Pole position lasts for 3 days. More information [here](https://www.blocket.se/for-foretag/fordon/pole-position). Charges apply.

**Prerequisites:** The ad must be visible (`visible=true`) and must not already have an active Pole Position. Only available for registered vehicle categories (Blocket only).

## Vehicle field values {#vehicle-field-values}

Valid values for fields like `body_type`, `brand` and `fuel` are listed directly in the [Swagger UI](swagger-ui/) schema for each category. Open `POST /v5/{vehicle_type}` (e.g. `POST /v5/car`) or `POST /v4/{vehicle_type}`, click **Schema**, and expand `category_fields` to see the accepted enum values.

> **Note:** V5 and V4 may accept different enum values for the same field. Always use the lookup endpoints matching the API version you are integrating with.

You can also discover attributes and their valid values programmatically:

    GET /v5/vehicles/{vehicle_type}/attributes
    GET /v4/vehicles/{vehicle_type}/attributes

Returns a list of queryable attributes for the given vehicle type. Each entry has an `id` and a human-readable `name`:

```json
[
    {"id": "body_type", "name": "Body Type"},
    {"id": "brand", "name": "Brand"},
    {"id": "powertrain.fuel", "name": "Powertrain Fuel"}
]
```

To retrieve the allowed values for a specific attribute:

    GET /v5/vehicles/{vehicle_type}/{attribute}
    GET /v4/vehicles/{vehicle_type}/{attribute}

Returns a list of valid values, each with an `id` (slug) and `name`:

```json
[
    {"id": "volvo", "name": "Volvo"},
    {"id": "bmw", "name": "BMW"}
]
```

For example, to list all valid brands for boats: `GET /v5/vehicles/boat/brand`

For boat, bus, truck, construction, agriculture-thresher, agriculture-tractor and agriculture-tools, V5 accepts the same values as V4, and the V5 and V4 lookups return the same lists. Trailer has no V5 lookups.

For cars, you can also look up models for a specific brand:

    GET /v5/vehicles/car/models?brand={brand}
    GET /v4/vehicles/car/models?brand={brand}

On V5 this list is also what `model` is validated against for Car and Transport — Transport uses the same model list as Car — so use it to find the exact slug to send.

# V5 API

> **Use `/v5/{vehicle_type}/` for new integrations** in the registered vehicle categories.

**V5 changed the shape of the eight registered vehicle categories**: `car`, `transport`, `motorcycle`, `moped`, `snowmobile`, `atv`, `camper`, `caravan`. Those are the ones with updated enum values, the `powertrain.fuel` rename, and the migration path described below.

V5 also *serves* boats, agriculture, bus, truck and construction, using the same schema V4 uses. Nothing changed for them, so there is nothing to migrate: you can create and update those ads through `/v5/{vehicle_type}/` straight away, including ads that were last written by V4. A V3 ad in one of the categories whose schema changed between V3 and V4 (boats, agriculture, Truck & Bus, construction) is refused with `400 incompatible_api_version`, as it is on V4: migrate it to V4 first, see [Migrating V3 ads to V4](#migrating-v3-ads-to-v4). Trailer is the only vehicle type with no V5 endpoint — keep using V4 for it. Through `/v5/ad/{source_id}` an existing trailer ad can be read and deleted, but `PUT`, `PATCH`, `bump`, `pole_position` and `retry` return `400` with `error: trailer_patch_not_supported`.

## V5 Endpoint Overview

### Generic endpoints

| Method | Path | Description |
| :---- | :---- | :---- |
| `GET` | `/v5/ad` | List ads (returns V3, V4 and V5 ads) |
| `GET` | `/v5/ad/{source_id}` | Get specific ad |
| `DELETE` | `/v5/ad/{source_id}` | Delete ad |
| `GET` | `/v5/ad/{source_id}/log` | Get ad logs |
| `GET` | `/v5/ad/{source_id}/bump` | Renew an ad |
| `GET` | `/v5/ad/{source_id}/pole_position` | Set pole position on an ad |
| `GET` | `/v5/ad/{source_id}/retry` | Re-queue ad for processing |
| `GET` | `/v5/migration-preview` | Dry run: which of your ads can move to V5 (see below) |

### Enum value lookup

| Method | Path | Description |
| :---- | :---- | :---- |
| `GET` | `/v5/vehicles/{vehicle_type}/attributes` | List available attributes for a vehicle type |
| `GET` | `/v5/vehicles/{vehicle_type}/{attribute}` | Get valid values for an attribute |
| `GET` | `/v5/vehicles/car/models?brand={brand}` | Valid `model` slugs for a brand (Car and Transport) |

### Typed endpoints

| Method | Path | Description |
| :---- | :---- | :---- |
| `POST` | `/v5/{vehicle_type}` | Create new ad |
| `GET` | `/v5/{vehicle_type}` | List ads for category |
| `POST` | `/v5/{vehicle_type}/validate` | Validate payload without saving |
| `GET` | `/v5/{vehicle_type}/{source_id}` | Get specific ad |
| `PUT` | `/v5/{vehicle_type}/{source_id}` | Full update (V5 ads only, on the registered vehicle types — see below) |
| `PATCH` | `/v5/{vehicle_type}/{source_id}` | Partial update (V5 ads only, on the registered vehicle types — see below) |
| `DELETE` | `/v5/{vehicle_type}/{source_id}` | Delete ad |
| `POST` | `/v5/{vehicle_type}/{source_id}/migrate` | Migrate a V3/V4 ad to V5 (see below) |

## V5 Backward Compatibility

| Operation | On a V5 ad | On a V3/V4 ad |
| :---- | :---- | :---- |
| **GET** | Works | Works — except V3 caravans, campers and mopeds, see below |
| **DELETE** | Works | Works — V3 caravans, campers and mopeds answer in a short form, see below |
| **PUT / PATCH** | Works | Blocked — `400 migration_required` — on the eight registered vehicle types. Blocked — `400 incompatible_api_version` — on V3 ads whose category changed between V3 and V4, as on V4. Works everywhere else |
| **PUT / PATCH through V3 or V4** | Blocked — `400 incompatible_api_version` — on the eight registered vehicle types. Works everywhere else | Works |
| **Read through V3 or V4** | On the eight registered vehicle types: short form in lists and in the answer to `DELETE`, bump and pole_position; a single `GET` answers `400 incompatible_api_version` — see below. Works everywhere else | Works |

**The block applies to the vehicle types V5 changed**, which is Car, Transport, Motorcycle, Moped, Snowmobile, ATV, Camper and Caravan. Outside those, V5 serves a category through the very same schema V4 uses, so there is nothing for an update to misread and a V3 or V4 ad can be written through V5 directly — `PATCH /v5/boat` on a V4 boat succeeds. `GET /v5/migration-preview` reports such ads as `nothing_to_migrate`.

**An ad never moves back from V5.** Once an ad of one of these eight types is on V5, `PUT` and `PATCH` through `/v3/ad`, `/v4/ad` or `/v4/{vehicle_type}`, and `POST /v4/{vehicle_type}/{source_id}/migrate`, return `400` with `error: incompatible_api_version`, and `migration_options` names the V5 endpoint to use. If you move to V5 one part of your integration at a time, write each migrated ad through V5 only.

**V3 and V4 do not show a V5 ad of these eight types**, because its fields are in a shape their schemas do not describe. It stays in the lists of `/v3/ad`, `/v4/ad` and `/v4/{vehicle_type}`, so that an integration syncing off the list does not read it as deleted, but in a short form: every field the V3 and V4 schemas require, so a client generated from them can still read the page, and no `category_fields`:

```json
{
  "id": "4f1c…",
  "source_id": "car-001",
  "api_version": "v5",
  "category_id": "1020",
  "state": "created",
  "blocket_ad_id": "1207654321",
  "offer_id": "7c2e…",
  "created": "2026-10-13T09:12:44.512Z",
  "updated": "2026-10-13T09:12:47.031Z",
  "image_refs": [],
  "log": [ … ],
  "error": "incompatible_api_version",
  "message": "This ad is on V5, which stores vehicle fields in a shape the V4 schema does not describe, so it is not shown here. Use GET /v5/car/{source_id}.",
  "migration_options": [{"method": "Use V5", "description": "Read and manage the ad through the V5 endpoints, as for any V5 ad.", "steps": ["GET /v5/car/{source_id}"]}]
}
```

`DELETE`, `bump` and `pole_position` through V3 or V4 work on such an ad as before and answer with the same short form. A single `GET /v3/ad/{source_id}`, `/v4/ad/{source_id}` or `/v4/{vehicle_type}/{source_id}` returns `400` with the same `error` and `migration_options`, plus `details`. Read the ad through V5 instead, and follow a `DELETE` of it there too: `GET /v5/{vehicle_type}/{source_id}`.

**No update moves an ad onto V5.** Only `POST .../migrate` does that, because only it sends a complete payload. Where V5 accepts a write to an older ad — the categories it shares with V4 — the ad's `api_version` records the schema that validated it, exactly as the matching V4 endpoint would: a V4 ad stays `v4`, and a V3 ad becomes `v4`. Read `api_version` back from the ad rather than assuming which endpoint you used decides it.

`category_fields` is stored in the shape of whichever version last wrote a complete payload, and an update merges into what is stored. A partial update through a V5 endpoint can therefore only validate the fields you send, while the old values stay underneath on an ad now marked as V5 — and the two shapes disagree. A V4 car carries `powertrain.fuels: ["diesel"]`; V5 reads `powertrain.fuel`, so the published ad would lose its fuel with no error anywhere. Rather than half-convert the ad, V5 refuses the write and asks for a complete payload.

The rejection tells you where to go:

```json
{
    "error": "migration_required",
    "message": "Cannot update a V4 ad through a V5 endpoint. ...",
    "details": {"current_api_version": "v4", "category_id": "1020", "source_id": "my-car-2024"},
    "migration_options": [ ... ],
    "preview": "GET /v5/migration-preview lists which of your ads are ready to migrate and what blocks the rest."
}
```

### Reading V3/V4 ads through V5

`GET` and `DELETE` on `/v5/{vehicle_type}` return every ad, whichever version last wrote it, in the shape it is stored in. **Read `api_version` before `category_fields`:** on the eight registered vehicle types, `v5` means the V5 shape, while `v3` and `v4` mean an ad not yet migrated, whose `category_fields` follow the V4 schema — `powertrain.fuels` rather than `powertrain.fuel`, and V4 values such as `station_wagon`. A list page can hold both. The OpenAPI schema describes this as a `oneOf` with a discriminator on `api_version`, so a client generated from it gets the right type for each ad. Writes (`POST`, `PUT`, `PATCH`, `POST .../migrate`) always answer with a V5 ad.

On these eight types the typed responses carry no `contact` or `title`: a registered vehicle ad must never send them, so they are not returned either. `category_id` is returned, and is never sent — the URL gives it. `GET /v5/ad/{source_id}` returns every field, as before.

### V3 caravans, campers and mopeds: migrate on V4 first

A caravan, camper or moped created through V3 is published as a general ad, with a `title` and a `contact`, not as a registered vehicle — V4 and V5 publish these vehicle types as registered vehicles. V5 cannot serve such an ad directly, so on `/v5/caravan`, `/v5/camper` and `/v5/moped`:

| Operation | V3 caravan, camper or moped |
| :---- | :---- |
| **GET** one ad, **PUT**, **PATCH**, **POST .../migrate** | `400` with `error: migrate_on_v4_first` |
| **GET** the list | Listed, in a short form: `id`, `source_id`, `api_version`, `category_id`, `state`, `error`, `message` and `migration_options` |
| **DELETE** | Accepted, exactly as on V3 and V4; the response is the same short form |

The ad is listed rather than left out so that a list never makes it look deleted, and it can be deleted without migrating it first. `GET /v5/ad/{source_id}` and `GET /v5/ad` still return it in full, `PUT`/`PATCH /v5/ad/{source_id}` answer `migrate_on_v4_first` like the typed endpoints, and V3 and V4 keep serving it as before.

To bring it to V5, migrate it on V4 first with `POST /v4/{vehicle_type}/{source_id}/migrate` and a complete V4 payload — `migration_options` names the exact endpoint — and then migrate it to V5 like any V4 ad. A deleted ad has nothing to migrate: its `migration_options` is empty and the `message` says so. The response to a `DELETE` says the deletion is queued, not done — the typed endpoint shows no state or log for these ads, so follow the deletion on `GET /v5/ad/{source_id}`, which every such response names. `GET /v5/migration-preview` reports these ads with a single `migrate_on_v4_first` issue and counts them under `summary.migrate_on_v4_first`, apart from `blocked`.

## Migrating V3/V4 ads to V5

### Step 1: See what you are in for

    GET /v5/migration-preview

A dry run over your own ads. Nothing is written and nothing is queued. For each ad it reports whether resending it unchanged would be accepted by the migrate endpoint, and if not, exactly which fields stand in the way. "Unchanged" means the ad as `GET /v5/{vehicle_type}/{source_id}` returns it, without the read-only fields `id`, `api_version`, `category_id`, `state`, `offer_id`, `blocket_ad_id`, `created`, `updated`, `image_refs` and `log` — `price`, `image_urls` and the other top-level fields are checked as well as `category_fields`. An ad without images reads back as `image_urls: null`, which no write accepts: leave the field out.

| Parameter | Description |
| :---- | :---- |
| `category_id` | Restrict to one category |
| `only` | `blocked` or `ready` — filter the listing (the summary always counts everything examined) |
| `limit` | Ads per page, default 100, from 1 to 500. A value outside that range is clamped to the nearest end, and the response echoes the `limit` actually used |
| `offset` | Offset into the result set. A negative value is treated as 0 |

```json
{
    "summary": {
        "total": 100,
        "ready": 0,
        "blocked": 100,
        "unavailable": 0,
        "nothing_to_migrate": 0,
        "migrate_on_v4_first": 0,
        "blocked_by_field": {
            "category_fields.powertrain.fuels": 100,
            "category_fields.model": 29
        },
        "matching_ads": 412,
        "examined": 100,
        "note": "Counts cover the ads on this page only. Page through with limit/offset to cover the whole stock."
    },
    "limit": 100,
    "offset": 0,
    "results": [
        {
            "source_id": "my-bmw-118",
            "category_id": "1020",
            "api_version": "v4",
            "ready": false,
            "issues": [
                {
                    "field": "category_fields.powertrain.fuels",
                    "value": ["diesel"],
                    "message": "`powertrain.fuels` is a V4 field. Send `powertrain.fuel: \"diesel\"` instead.",
                    "suggestions": ["diesel"]
                },
                {
                    "field": "category_fields.body_type",
                    "value": "station_wagon",
                    "message": "`station_wagon` is the V4 name. Send `station-wagon` instead.",
                    "suggestions": ["station-wagon"]
                },
                {
                    "field": "category_fields.model",
                    "value": "118",
                    "message": "Model '118' is not in the model list for brand 'bmw'. V5 names the engine variant where V4 named the series, so pick the matching one from GET /v5/vehicles/car/models?brand=bmw.",
                    "suggestions": ["118d", "118i"]
                }
            ]
        }
    ]
}
```

Ads already on V5, and deleted ads, are left out. Ads in a category V5 does not serve at all are reported as blocked on `category_id` — keep those on V4.

**Ads V5 already accepts as they stand have nothing to migrate.** Outside the eight registered vehicle types, V5 serves a category through the very same schema V4 uses, so there is no shape to convert. Those ads carry a single issue whose `field` is `nothing_to_migrate`, naming the category, and are counted under `summary.nothing_to_migrate` rather than `summary.blocked`. Do not wait for them: write to them directly with `PUT`/`PATCH /v5/{vehicle_type}/{source_id}`, which V5 accepts on a V3 or V4 ad in these categories. `POST .../migrate` refuses them with `migration_not_needed`, which is why they are not counted as ready either.

**If our vehicle data service is unreachable while an ad is examined**, that ad is reported with a single issue whose `field` is `taxonomy_unavailable`, and counted under `summary.unavailable` rather than `summary.blocked`. It means we could not check the ad, not that anything is wrong with it — request the page again in a few minutes. An unchecked ad carries no suggestions, because we never read the list they would come from. It is still returned by `only=blocked`, since it is not ready either. `POST .../migrate` answers `500` in the same situation, so the dry run and the write agree on whose problem an outage is.

**If the stored ad itself could not be analysed**, it carries a single issue with `field: null` and a message beginning "Could not analyse this ad". It counts as blocked, under `blocked_by_field["unknown"]`. Ask us about such an ad; resending the page will not change the answer.

`ready`, `blocked`, `unavailable`, `nothing_to_migrate` and `migrate_on_v4_first` add up to `total` — reconcile on all five. The last three are not verdicts on the ad's fields and are kept out of `blocked_by_field`, which is a work list: an ad we could not check has no known offending field, an ad V5 already serves has no field to fix, and a V3 caravan, camper or moped has to go through V4 first. All three are still returned by `only=blocked`, since none is ready to migrate.

Once one ad on a page has failed that way, the rest of the page is reported the same way without waiting on the lookup again. The page therefore comes back in its usual time rather than stalling, and a non-zero `unavailable` means exactly one thing: request the page again. Verdicts that need no lookup are unaffected — an ad in a category V5 does not serve is still reported as such.

### Step 2: Migrate

    POST /v5/{vehicle_type}/{source_id}/migrate

Converts the ad in-place. The ad ID, `source_id` and history are preserved. Requires a **complete** V5 payload — `category_fields` is replaced outright, not merged, which is the whole point: no V4-shaped value can survive underneath. Do **not** include `category_id` in the request body; it comes from the endpoint URL.

**It is validated as an update of the ad, not as a new ad**, because that is what it is: the ad and its listing already exist. A `reduced` price is accepted, and neither `registration_number` nor `vin` is required. `registration_number` cannot be changed, so leave it out — the ad keeps the one it has. That is the one value kept when it is not sent. A stored registration number that is not a valid one, typically a temporary number beginning with `Q` assigned when the ad was created with only a `vin`, is refused if you send it back, and the preview tells you to leave it out.

On success the response is the migrated ad exactly as `GET` would return it, with a `migration_info` object attached naming the version it came from.

Errors. A refusal names the condition in `error`; an invalid payload is the ordinary field-error object instead.

| `error` | Meaning |
| :---- | :---- |
| `ad_already_v5` | Nothing to do — use `PUT`/`PATCH` |
| `ad_deleted` | The ad is deleted |
| `migration_not_needed` | V5 serves this category with the same schema V4 uses, so there is nothing to convert. Write to the ad directly with `PUT`/`PATCH` |
| `category_fields_required` | The body has no `category_fields` object. Send the complete V5 ad |
| *(field errors)* | The payload is not valid V5 — see [Error Format](#error-format) |

The endpoint exists on every V5 vehicle type, including the ones that need no migration — so that a client moving a mixed stock gets an answer saying which kind of no it means, rather than a `404`. On those types it always returns `migration_not_needed`.

Trailer is the one vehicle type with no V5 endpoint at all, so there is no `POST /v5/trailer/{source_id}/migrate` to call. `GET /v5/migration-preview` reports trailer ads on `category_id` — that is where you will see them.

### What blocks a migration, and what the preview does about it

**We never change a value for you.** The preview tells you what each value should become; you send it. The tables below are the same mapping, for building V5 payloads from your own system.

#### `powertrain.fuels`

V5 replaced the list `powertrain.fuels` with the single string `powertrain.fuel`. V4 requires `fuels`, so every car and transport ad you have carries it:

```diff
  "powertrain": {
      "transmission": "automatic",
-     "fuels": ["diesel"]
+     "fuel": "diesel"
  }
```

The preview's `suggestions` names the value. Most lists have one obvious answer, and you can apply it as-is.

**One case has two answers.** V4's `["gasoline", "electric"]` describes both a full hybrid and a plug-in hybrid; V5 tells them apart. We look the vehicle up in the Swedish vehicle register by its registration number and suggest the one that matches. When the register cannot answer — it is unreachable, or the ad has no registration number — you get both candidates and a message saying we could not tell:

```json
{
    "field": "category_fields.powertrain.fuels",
    "value": ["gasoline", "electric"],
    "message": "`powertrain.fuels` is a V4 field and V5 takes the single `powertrain.fuel`. The vehicle register could not tell us which of these this vehicle is, so the choice is yours.",
    "suggestions": ["hybrid-petrol", "plug-in-petrol"]
}
```

The whole mapping, for the lists V4 accepts:

| V4 `fuels` | V5 `fuel` |
| :---- | :---- |
| `["gasoline"]` | `petrol` |
| `["diesel"]` | `diesel` |
| `["electric"]` | `electricity` |
| `["ethanol"]` or `["gasoline", "ethanol"]` | `ethanol-ffv-e85` |
| `["natural_gas"]` | `gas-cng` |
| `["gasoline", "natural_gas"]` | `gas-petrol` |
| `["gasoline", "electric"]` | `hybrid-petrol` or `plug-in-petrol` |
| `["diesel", "electric"]` | `hybrid-diesel` or `plug-in-diesel` |
| `["diesel", "natural_gas"]` | No equivalent. Pick the closest value from the lookup |

The order of the V4 list does not matter. V5 also has `hydrogen`. `GET /v5/vehicles/{vehicle_type}/fuel` lists every value.

Motorcycle, moped, ATV and snowmobile additionally drop `powertrain.transmission` on V5 — remove it rather than renaming it.

#### `powertrain.drive_type`

Car, Transport and Camper spell the drive types out on V5. The preview names the value.

| V4 | V5 |
| :---- | :---- |
| `fwd` | `front-wheel-drive` |
| `rwd` | `rear-wheel-drive` |
| `awd` | `four-wheel-drive` |

#### `body_type`

On Car and Transport, V5 names body types differently from V4, and three of the differences are a straight rename:

| V4 | V5 |
| :---- | :---- |
| `station_wagon` | `station-wagon` |
| `minibus` | `mpv` |
| `flatbed` (transport) | `pickup` |

`sedan`, `suv`, `convertible` and `coupe` mean the same in both and need no change.

**`hatchback` is the one that needs a decision from you.** V5 has `3-door-hatchback` and `5-door-hatchback` where V4 had one value, and your stored ad does not record a door count — so we cannot pick for you. The preview offers both and says so.

A transport ad has only two body types on V5, `pickup` and `van`. If yours is stored as anything else, the ad is a passenger car as far as V5 is concerned, and the body type has to change before it will migrate.

**The other six vehicle types have a different list on V5, not renamed values.** A caravan, for example, is `caravan`, `static-caravan` or `trailer-tent` where V4 had `1-axle` and `2-axle`, and a snowmobile has the single value `snowmobile`. There is no table for these: pick the value from `GET /v5/vehicles/{vehicle_type}/body_type`. The preview reports a body type V5 does not have and names that lookup.

#### `brand`

Almost every brand is spelled the same on V5, but a few are not. The preview reports a brand V5 does not have, and `GET /v5/vehicles/{vehicle_type}/brand` lists the valid ones.

**Nothing else changed shape.** V5 has the same fields as V4, apart from `powertrain.fuel` and the dropped `powertrain.transmission` above and an optional `powertrain.displacement` on Moped. A V4 payload with these values changed, and a `model` V5 accepts (next section), is a valid V5 payload.

### What usually blocks a migration: `model`

On V5, `model` is validated against the vehicle taxonomy for **Car and Transport**, matched on the slug. The taxonomy is more granular than the list V4 validated against, in three ways: it names the engine variant (`118` → `118d`, `118i`), the generation (`golf` → `golf-vii`, `golf-viii`) and the body series (`sprinter` → `sprinter-211`, `sprinter-311`). Around 13% of car ads and 15% of transport ads currently carry a model that needs a more specific slug.

The affected ads are concentrated rather than spread evenly: 15 brand/model combinations account for 60% of them, Volkswagen Golf generations and Mercedes-Benz series letters above all. Depending on what you stock, this is either a substantial job or almost none — run the preview and see.

There is no lossless automatic mapping — only you know whether `118` was a `118d` or a `118i`. That is what the preview's `suggestions` are for: it offers the candidates that match your stored value, and you pick.

**The preview also reads your `model_type`.** That field is free text and V5 does not validate it, but it usually spells out exactly the variant the taxonomy is asking for. An ad with `model: "118"` and `model_type: "118d Sport Line Aut"` gets a single suggestion, `118d`, instead of both variants; `model: "e"` with `model_type: "300 de 4MATIC"` gets `e300-de` ahead of `e300`. Across the live car and transport stock this narrows about half the blocked ads to one candidate. Where `model_type` says nothing useful you get the same list you would have got anyway, so there is nothing to switch on and nothing to lose.

Suggestions are still only suggestions. They are matched on text, not on vehicle data, so check one before you send a few thousand of them.

The awkward case is a broad stored value whose `model_type` does not name a variant either. Mercedes-Benz series letters are the common example: `mercedes-benz/e` is not a model in the taxonomy at all, and 86 slugs begin with `e`, so what you get is the first few of a long list — `e200`, `e200-d`, `e220`, `e220-d` and so on. The one you want is almost certainly in the taxonomy; the suggestions just cannot tell you which. That brand has 650 models in total, so the listing is the practical way in.

Volkswagen Golf is the other shape of this, and the largest single group. The taxonomy wants a generation (`golf-vii`, `golf-viii`) and a `model_type` like `"LIFE 1,5 ETSI 150 HK DSG7"` describes the engine instead, so it cannot help. Go by the model year.

Harder still is a stored value with no counterpart at any level — `audi/audi`, or a trim written into `model` such as `c63-s`. Nothing is offered for those because nothing in the taxonomy starts with them; look the brand up and pick the real model.

Look the exact slugs up with `GET /v5/vehicles/car/models?brand={brand}` (Transport uses the same model list as Car).

> **`model` is enforced everywhere on V5** — create, update and migrate alike. A value the taxonomy does not know returns `400`. The point of moving an ad to V5 is that blocket.se shows the model the vehicle actually is rather than the closest guess, so there is no version of this that accepts an approximation quietly.
>
> If you believe a model is genuinely missing from the taxonomy, tell us and we will have it added. Meanwhile the brand's catch-all entry lets you publish — check whether your brand has one in the model listing.

### Migration Strategy

The same as for V4: **gradual**. An ad is on one version at a time and different ads can be on different versions, so you can move step by step:

1. Update your client for V5, using the checklist below. The [Category Reference](category-reference) has a complete V5 example for each vehicle type.
2. Create new registered vehicle ads on `/v5/{vehicle_type}/`.
3. Run `GET /v5/migration-preview` to size the job and find the ads that need a hand.
4. Fix what blocks them in your own system — usually the fuel, `body_type` and `model`.
5. Migrate in batches with `POST /v5/{vehicle_type}/{source_id}/migrate`. From then on, write each migrated ad through V5 only.

#### Checklist for your client code

* Base URL `/v5/`, with the typed endpoints `/v5/{vehicle_type}`.
* `powertrain.fuel` as a single string instead of the `powertrain.fuels` list, and no `powertrain.transmission` on Motorcycle, Moped, Snowmobile and ATV.
* Your values mapped to V5: fuel, drive type, body type and brand (above), and the `model` slug for Car and Transport.
* The new `error` codes: `migration_required`, `incompatible_api_version`, `migrate_on_v4_first` and `trailer_patch_not_supported`, and on migrate `ad_already_v5`, `ad_deleted`, `migration_not_needed` and `category_fields_required`.
* In lists, `api_version` read before `category_fields`: an ad not yet migrated comes back in the V4 shape.
* No `contact` or `title` expected on registered vehicle ads in typed responses.
* When resending an ad you read back: leave out the read-only fields listed under Step 1, leave out `image_urls` if it is `null`, and leave out `registration_number` on migrate.
* A migrated ad written through V5 only, since V3 and V4 refuse writes to it.

## V5 FAQ

**Can I read and delete my V4 ads through V5?**
Yes. On the eight registered vehicle types only `PUT` and `PATCH` are refused until the ad is migrated; `bump`, `pole_position` and `retry` work. Trailer ads can only be read and deleted.

**Why does V5 block updates when V4 auto-converted them?**
Because every registered vehicle category changed shape on V5, and an update that merges into stored data cannot revalidate what it does not send. See [V5 Backward Compatibility](#v5-backward-compatibility) above.

**Can I mix versions?**
Yes, per ad. An ad is on exactly one version at a time; different ads can be on different versions.

# V4 API

> **Use `/v4/{vehicle_type}/` for new integrations.**

## V4 Endpoint Overview

### Generic endpoints

| Method | Path | Description |
| :---- | :---- | :---- |
| `GET` | `/v4/ad` | List ads (returns both V3 and V4 ads) |
| `GET` | `/v4/ad/{source_id}` | Get specific ad |
| `DELETE` | `/v4/ad/{source_id}` | Delete ad |
| `GET` | `/v4/ad/{source_id}/log` | Get ad logs |
| `GET` | `/v4/ad/{source_id}/bump` | Renew an ad |
| `GET` | `/v4/ad/{source_id}/pole_position` | Set pole position on an ad |
| `GET` | `/v4/ad/{source_id}/retry` | Re-queue ad for processing |

### Enum value lookup

| Method | Path | Description |
| :---- | :---- | :---- |
| `GET` | `/v4/vehicles/{vehicle_type}/attributes` | List available attributes for a vehicle type |
| `GET` | `/v4/vehicles/{vehicle_type}/{attribute}` | Get valid values for an attribute |

### Typed endpoints (`{vehicle_type}` e.g. `car`, `boat`, `truck`, etc.)

| Method | Path | Description |
| :---- | :---- | :---- |
| `POST` | `/v4/{vehicle_type}` | Create new ad |
| `GET` | `/v4/{vehicle_type}` | List ads for category |
| `POST` | `/v4/{vehicle_type}/validate` | Validate payload without saving |
| `GET` | `/v4/{vehicle_type}/{source_id}` | Get specific ad |
| `PUT` | `/v4/{vehicle_type}/{source_id}` | Full update |
| `PATCH` | `/v4/{vehicle_type}/{source_id}` | Partial update |
| `DELETE` | `/v4/{vehicle_type}/{source_id}` | Delete ad |
| `POST` | `/v4/{vehicle_type}/{source_id}/migrate` | Migrate V3 ad to V4 (see [Migrating V3 ads to V4](#migrating-v3-ads-to-v4)) |

Available vehicle types: `car`, `transport`, `motorcycle`, `moped`, `snowmobile`, `atv`, `camper`, `caravan`, `trailer`, `boat`, `agriculture-thresher`, `agriculture-tractor`, `agriculture-tools`, `bus`, `truck`, `construction`

> **Note:** Creating new **trailer** (`1045`) ads is no longer supported on either V3 or V4. `POST /v4/trailer`, `POST /v4/ad`, and `POST /v3/ad` with `category_id` `1045` return `400` with `error: trailer_create_disabled`. Existing trailer ads can still be retrieved, updated (`PUT`/`PATCH`) and deleted on both versions.

## V4 Backward Compatibility

If you have existing V3 ads, V4 endpoints handle them as follows. Some categories changed schema between V3 and V4 (e.g. Moped, Camper, Boats, Agriculture, Truck & Bus) — these require explicit migration before they can be updated via V4.

| Operation | Compatible (Car, MC, etc.) | Incompatible (Moped, Camper, Boats, etc.) |
| :---- | :---- | :---- |
| **GET** | Works | Works |
| **DELETE** | Works | Works |
| **PUT / PATCH** | Auto-converts to V4 | Blocked — use `/v4/{vehicle_type}/{source_id}/migrate` first |

## Migrating V3 ads to V4

### Compatible Categories (Car, Motorcycle, etc.)

Migration is **automatic** — simply update the ad via a V4 endpoint and it will be converted to V4.

### Incompatible Categories (Moped, Camper, Caravan, Trailer, Boats, Agriculture, Truck & Bus)

You have two options:

**Option A: Use the typed migration endpoint (recommended)**

`POST /v4/{vehicle_type}/{source_id}/migrate` converts the ad in-place. The ad ID, source ID and history are preserved. Requires a complete V4 payload with all required `category_fields`. Do **not** include `category_id` in the request body — it is determined by the endpoint URL.

For Moped, Camper, Caravan and Trailer a body without `category_fields` returns `400` with `error: category_fields_required`, and the ad stays on V3 — V3 published these as general ads with no `category_fields`, so there is nothing stored to fall back on.

Available migration endpoints:

| V3 Category | Endpoint | Target V4 category |
| :---- | :---- | :---- |
| Moped (1121) | `POST /v4/moped/{source_id}/migrate` | 1121 |
| Camper (1102) | `POST /v4/camper/{source_id}/migrate` | 1102 |
| Caravan (1101) | `POST /v4/caravan/{source_id}/migrate` | 1101 |
| Trailer (1045) | `POST /v4/trailer/{source_id}/migrate` | 1045 |
| Boats (1061–1067) | `POST /v4/boat/{source_id}/migrate` | 1060 (unified) |
| Agriculture Tools (1225, 1226) | `POST /v4/agriculture-tools/{source_id}/migrate` | 1229 (unified) |
| Agriculture (1222) → Thresher | `POST /v4/agriculture-thresher/{source_id}/migrate` | 1227 |
| Agriculture (1222) → Tractor | `POST /v4/agriculture-tractor/{source_id}/migrate` | 1228 |
| Truck & Bus (1221) → Bus | `POST /v4/bus/{source_id}/migrate` | 1321 |
| Truck & Bus (1221) → Truck | `POST /v4/truck/{source_id}/migrate` | 1322 |
| Construction (1223, 1224) | `POST /v4/construction/{source_id}/migrate` | 1323 (unified) |

> **Note:** Only the combinations listed above are supported — the migrate endpoint you call must match the ad's own category. An ad's category cannot be changed after it has been published: migration only converts the ad from the V3 to the V4 schema, it never moves an ad between categories. This is why, for example, an Agriculture (1222) ad can only be migrated to Thresher (1227) or Tractor (1228) and not through `POST /v4/agriculture-tools/{source_id}/migrate`, and why a Moped (1121) ad can only be migrated through `POST /v4/moped/{source_id}/migrate`. Any mismatch between the endpoint and the ad's category returns `400` with `error: category_not_migratable_to_target`, listing the endpoints that are available for that ad. If the ad's category has no migrate endpoint at all, the response says so and points to `PUT`/`PATCH` instead — those categories use the same schema in V3 and V4 and are converted automatically on update.

> **Note:** For categories that were split in V4 (Agriculture 1222 → Thresher/Tractor, Truck & Bus 1221 → Bus/Truck), choose the endpoint that matches the target category. If a V3 ad was created in the wrong category (e.g. a tractor listed as a thresher), it cannot be corrected via migration — you must delete the ad and create a new one in the correct category.

**Option B: DELETE + POST**

Delete the V3 ad and create a new V4 ad with a new `source_id`. The internal ad ID and history will also be new.

### Migration Strategy

We recommend a **gradual migration**: start using `/v4/{vehicle_type}/` for new ads, keep existing V3 ads unchanged, and migrate them step by step.

## V4 FAQ

**Do I need to migrate all ads at once?**
No. V3 ads continue to work, and you can migrate them one at a time.

**Can I still use V3 endpoints?**
Yes. V3 endpoints remain available. New features will be V4-only.

**Can I read V3 ads using V4 endpoints?**
Yes. `GET /v4/ad` returns both V3 and V4 ads.

**Do I need to change my authentication?**
No. The same API token works for both V3 and V4.

# Migration from file imports via FTP {#migration-from-file-imports-via-ftp}

The Import-API is very different from the legacy file imports where you send a file via FTP with the entire stock and wait for that file to be imported. The imports via FTP require you to send all the stock information on every update, and images are sent separately either as raw image files or via URLs in json-files.

The API is a modern replacement to the previous file imports via FTP which is now being deprecated.

### **Migrating to the API** {#migrating-to-the-api}

When migrating to the API, all existing ads currently managed in **Blocket Admin** must be re-submitted to the API using `POST` requests. This is necessary to establish the `source_id` relationship between the API-managed ad and the corresponding ad in Blocket Admin. Matching is based on licence plate, including Q based licence plates allocated automatically when the ad was created manually in Blocket Admin.

During this initial migration, you are also required to provide a list of image URLs via the `image_urls` field. Below follows a short recap and caveats you need to be aware of when migrating from legacy file imports or building a new integration.

**Source ID**

As described in the documentation above, every ad needs a source_id, this is your identifier when updating or deleting the ad after creation. The source_id needs to be unique within the customer it belongs to. The source_id can be any string of choice.

**Images**

As described in the documentation above, images are sent as a list of URLs in the ad payload under the field named image\_urls. The images will be downloaded by the API when creating or updating the ad. There is no possibility to upload raw image files to the API, you need to provide URLs to your own publicly accessible image storage or CDN.

#### **Overwriting Data**

All data submitted through the API will **overwrite** the existing data in Blocket Admin. Unlike the previous file import system, there is **no concept of import locks** — any ad data submitted via the API is considered the source of truth.

#### **One-Way Sync**

Any changes made directly in Blocket Admin **will not** be reflected when retrieving the ad via the API. The API only exposes data that was created or updated through the API itself. For consistency and data integrity, **all ad modifications should preferably be performed via the API**.

#### **File Imports Deprecated**

Once the migration to the API is complete, the legacy file import functionality will be **shut down**.

#### **Step by step guide**

1. Stop sending legacy import files.
2. Send a POST request with source_id, licence\_plate etc for each existing ad to connect the existing ads to the API. See [POST /ad section](#post-/ad---create-an-ad).
3. Manage all existing and new ads through the API.
