Publishing adverts

Overview

Publishing adverts is probably the main reason you’re here for. By now you should have a registered application, know how to make requests, authorize users, advert payload, and validations that need to be in place to sends us a successful request. Let’s see how to publish an Advert.

Basic workflow

To publish an advert you need the following information:

  • Advert data: The actual advert data (example below)
  • Site URN: The URN of the site where you are publishing the advert (Supported sites)
  • Category URN: The category for your advert (check out the Taxonomy API)
  • Attribute URNs: Attributes make your advert more complete (also available in the Taxonomy API)

📘 Required fields
Note that depending on the category, certain fields are required for an advert to be valid. Make sure to check the Advert payload and validation rules page.

Publish payload example

You use the example below to test it out (you can also find it on our Postman Collection or check Advert payload and validation rules:


{
  "category_urn": "urn:concept:other",
  "title": "[qatest-mercury] Car part test. STG: urn:site:olxro",
  "description": "Car part in pristine condition. This advert is a test and should not be considered for any other aspect.",
  "contact": {
    "name": "Test User",
    "phone": "918888888",
    "email": "joaquim@silva.tudo",
    "photo": "https://s3.eu-central-1.amazonaws.com/tests-resources/public/mercury-test-logo.png"
  },
  "price": {
    "value": 230000,
    "currency": "EUR"
  },
  "location": {
      "custom_fields": {
        "city_id": 1,
        "district_id": 11
      },
      "exact": true,
      "lat": 44.44290,
      "level": null,
      "lon": 26.01849,
      "name": null,
      "postal_code": null
    },
  "images": [
    {
      "url": "https://s3.eu-central-1.amazonaws.com/tests-resources/public/re_images/re_image_1.jpg"
    },
    {
      "url": "https://s3.eu-central-1.amazonaws.com/tests-resources/public/re_images/re_image_2.jpg"
    }
  ],
  "site_urn": "urn:site:olxro",
  "attributes": [
      {
        "urn": "urn:concept:state",
        "value": "urn:concept:new"
      },
      {
        "urn": "urn:concept:tyres-width",
        "value": "urn:concept:parts-tyres-width-125"
      },
      {
        "urn": "urn:concept:tyres-type",
        "value": "urn:concept:parts-tyres-type-summer"
      }
    ],
  "custom_fields": {
    "id": "1658768201464",
    "reference_id": "MCY-d93c24b9-ba14-4127-a4e8-75055c0e25c0"
  }
}

Making the API Request

With the payload saved in advert.json, the following request will publish the advert:


curl --location --request POST 'https://api.olxgroup.com/advert/v1'\
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <YOUR API KEY>' \
--header 'Authorization: Bearer <ACCESS TOKEN>' \
--header 'User-Agent: <CRM NAME>'
--data-raw @advert.json \

If all went well, you should receive a Response with a 201 HTTP Status code, which looks like this:


{
    "transaction_id": "74c6bfc9-4163-11e8-a4a5-aff93b12a0c2",
    "message": "Data is valid",
    "data": {
        "uuid": "b195bdbc-9074-4bac-99a1-7248c0c98892",
        "last_action_status": "TO_POST"
    }
}

Great, you’re almost there! To check if the request went with success or not, prepare the Notification URL to handle with notifications. Learn more here: Setup notifications .