Advert Lifecycle

Advert Lifecycle Event Flow

Event flow name: advert_lifecycle

This event flow contains events related to the lifecycle of adverts. That means, any time an advert is updated on the site it was created, you will receive a notification with the status update. That can happen through a request made from the flow publish_advert or from any updates on site.

Currently, there's only one event available that informs you about changes to the status of an advert:

Event typeDescriptioncodeNext Available Operations
advert_state_changedAn event that is triggered when an advert state changes on the site it was createdmoderated
removed_by_moderator
PUT
(the ad details can be updated, but the status will remain the same)
outdatedPUT
ACTIVATE
DELETE
activePUT
DELETE
DEACTIVATE
removed_by_userPOST or
 ACTIVATE
(depending on the last operation)
new
blocked
PUT
DELETE
unpaidPOST
Only for Investments Units, when the Investment is removed/deactivatedremoved_by_parent_adPOST

advert_state_changed

📘

Advert status codes

Once an advert is published it can go through many states like getting removed by a user, moderated, expired, etc. Any time a state change is detected, you'll get a notification in your webhook. Make sure that your app is subscribed to these events in the Application Manager and check out the different status codes here .

Code: moderated/removed_by_moderator

The status of an advert was updated to moderated, the reason why was moderated is included in the lifecycle notification above, like in the example below:

{
    "data": {
        "activated_at": "2018-05-03 14:04:15",
        "code": "moderated",
        "created_at": "2018-04-19T13:47:53.000+0000",
        "visible_in_profile": true,
        "modified_at": null,
        "ttl": "2018-04-26T12:27:02.000+0000",
        "url": "<Advert URL>",
        "moderation": {
            "reason": "Moderation reason",
            "description": "Description of moderation reason"
        }
    },
    "destination": "https://myawesomeapp.com/webhooks",
    "event_type": "advert_state_changed",
    "flow": "advert_lifecycle",
    "object_id": "d6bd341e-90f5-43ed-8ab0-2be56f6054bc",
    "event_timestamp": 1531735505952,
    "timestamp": 1524148443449,
    "transaction_id": "de3cd53c-43cf-11e8-93ed-ff34ffa368f3"
}

Same for: removed_by_moderator.

Code: active

If an advert was activated after a moderation removal, or even after a POST request, you will receive the lifecycle notification like in the example below:

{
  "data": {
    "data": {
      "activated_at": "2020-06-24T08:02:30.000+0000",
      "code": "active",
      "created_at": "2020-06-24T07:56:58.000+0000",
      "visible_in_profile": true,
      "moderation": {
        "description": null,
        "reason": null
      },
      "modified_at": "2020-06-29T10:34:02.000+0000",
      "recorded_at": "2020-06-29T10:34:03.326+0000",
      "ttl": "2020-07-29T10:34:02.000+0000",
      "url": "https://www.imovirtual.com/anuncio/qatest-mercury-anuncio-de-testes-olx-group-ID13b0A.html"
    },
    "destination": "http://https://myawesomeapp.com/webhooks",
    "event_timestamp": 1593426844007,
    "event_type": "advert_state_changed",
    "flow": "advert_lifecycle",
    "object_id": "8e5d6763-20e7-46bc-90c4-93edc3cd3826",
    "timestamp": 1593426843326,
    "transaction_id": "bd553e9d-d983-4cc8-857e-0ec76bb314e3"
  }

Code: outdated

If an advert was outdated by the expiration, you will receive the lifecycle notification like in the example below:

{
  "data": {
    "data": {
      "activated_at": "2020-06-24T08:02:30.000+0000",
      "code": "outdated",
      "created_at": "2020-06-24T07:56:58.000+0000",
      "visible_in_profile": true,
      "moderation": {
        "description": null,
        "reason": null
      },
      "modified_at": "2020-06-24T08:02:46.000+0000",
      "recorded_at": "2020-06-29T10:30:05.221+0000",
      "ttl": "2020-06-29T10:30:05.000+0000",
      "url": null
    },
    "destination": "http://https://myawesomeapp.com/webhooks",
    "event_timestamp": 1593426605720,
    "event_type": "advert_state_changed",
    "flow": "advert_lifecycle",
    "object_id": "8e5d6763-20e7-46bc-90c4-93edc3cd3826",
    "timestamp": 1593426605221,
    "transaction_id": "0339661b-2b3a-45f0-92c4-56fa45e69f65"
  }

Code: removed_by_user

If an advert was removed by the user, you will receive the lifecycle notification like in the example below:

{
  "data": {
    "data": {
      "activated_at": "2020-06-24T08:02:30.000+0000",
      "code": "removed_by_user",
      "created_at": "2020-06-24T07:56:58.000+0000",
      "visible_in_profile": true,
      "moderation": {
        "description": null,
        "reason": null
      },
      "modified_at": "2020-06-24T08:02:46.000+0000",
      "recorded_at": "2020-06-29T10:30:05.221+0000",
      "ttl": "2020-06-29T10:30:05.000+0000",
      "url": null
    },
    "destination": "http://https://myawesomeapp.com/webhooks",
    "event_timestamp": 1593426605720,
    "event_type": "advert_state_changed",
    "flow": "advert_lifecycle",
    "object_id": "8e5d6763-20e7-46bc-90c4-93edc3cd3826",
    "timestamp": 1593426605221,
    "transaction_id": "0339661b-2b3a-45f0-92c4-56fa45e69f65"
  }

Code: new

This status can be returned when the advert was successfully created but it's not published yet. This is a transient state that usually lasts a few seconds and is followed by the activation of the advert.

{
  "data": {
    "data": {
      "activated_at": "2020-06-24T08:02:30.000+0000",
      "code": "new",
      "created_at": "2020-06-24T07:56:58.000+0000",
      "visible_in_profile": true,
      "moderation": {
        "description": null,
        "reason": null
      },
      "modified_at": "2020-06-24T08:02:46.000+0000",
      "recorded_at": "2020-06-29T10:30:05.221+0000",
      "ttl": "2020-06-29T10:30:05.000+0000",
      "url": null
    },
    "destination": "http://https://myawesomeapp.com/webhooks",
    "event_timestamp": 1593426605720,
    "event_type": "advert_state_changed",
    "flow": "advert_lifecycle",
    "object_id": "8e5d6763-20e7-46bc-90c4-93edc3cd3826",
    "timestamp": 1593426605221,
    "transaction_id": "a0c9c8a9-19fa-4c9f-84e4-077ed4d8c582"
  }

Code: blocked

This status can be returned after an update (PUT) sent to already moderated advert (code: moderated or code: removed_by_moderator):

{
  "data": {
    "data": {
      "activated_at": "2020-06-24T08:02:30.000+0000",
      "code": "blocked",
      "created_at": "2020-06-24T07:56:58.000+0000",
      "visible_in_profile": true,
      "moderation": {
        "description": null,
        "reason": null
      },
      "modified_at": "2020-06-24T08:02:46.000+0000",
      "recorded_at": "2020-06-29T10:30:05.221+0000",
      "ttl": "2020-06-29T10:30:05.000+0000",
      "url": null
    },
    "destination": "http://https://myawesomeapp.com/webhooks",
    "event_timestamp": 1593426605720,
    "event_type": "advert_state_changed",
    "flow": "advert_lifecycle",
    "object_id": "8e5d6763-20e7-46bc-90c4-93edc3cd3826",
    "timestamp": 1593426605221,
    "transaction_id": "a0c9c8a9-19fa-4c9f-84e4-077ed4d8c582"
  }

Code: unpaid

This status will be returned when an advert is pending payment. This situation can also occur when you create an advert (POST), then DELETE, and then POST again within 24 hours. The payment system only allows you to create one payment in 24 hours and will consider this situation an error and will return code: unpaid:

{
  "data": {
    "data": {
      "activated_at": "2020-06-24T08:02:30.000+0000",
      "code": "unpaid",
      "created_at": "2020-06-24T07:56:58.000+0000",
      "visible_in_profile": true,
      "moderation": {
        "description": null,
        "reason": null
      },
      "modified_at": "2020-06-24T08:02:46.000+0000",
      "recorded_at": "2020-06-29T10:30:05.221+0000",
      "ttl": "2020-06-29T10:30:05.000+0000",
      "url": null
    },
    "destination": "http://https://myawesomeapp.com/webhooks",
    "event_timestamp": 1593426605720,
    "event_type": "advert_state_changed",
    "flow": "advert_lifecycle",
    "object_id": "8e5d6763-20e7-46bc-90c4-93edc3cd3826",
    "timestamp": 1593426605221,
    "transaction_id": "a0c9c8a9-19fa-4c9f-84e4-077ed4d8c582"
  }

Therefore, it is better to use DEACTIVATE and ACTIVATE commands instead of DELETE if your system allows to activate the same adverts (same value in custom_fields.id field).

Code: removed_by_parent_ad

This status can only be returned for Investments Units, when the Investment is removed/deactivated:

{
  "data": {
    "data": {
      "activated_at": "2020-06-24T08:02:30.000+0000",
      "code": "removed_by_parent_ad",
      "created_at": "2020-06-24T07:56:58.000+0000",
      "visible_in_profile": true,
      "moderation": {
        "description": null,
        "reason": null
      },
      "modified_at": "2020-06-24T08:02:46.000+0000",
      "recorded_at": "2020-06-29T10:30:05.221+0000",
      "ttl": "2020-06-29T10:30:05.000+0000",
      "url": null
    },
    "destination": "http://https://myawesomeapp.com/webhooks",
    "event_timestamp": 1593426605720,
    "event_type": "advert_state_changed",
    "flow": "advert_lifecycle",
    "object_id": "8e5d6763-20e7-46bc-90c4-93edc3cd3826",
    "timestamp": 1593426605221,
    "transaction_id": "0339661b-2b3a-45f0-92c4-56fa45e69f65"
  }