# Syndication

The Foyer syndication system allows you to receive changes to followed listings. The api endpoints are outlined in detail below. You can elect to receive realtime notifications, as outlined below, or use our `refreshAllListings` endpoint to check for updates as desired.

**Push Notifications**

In order to receive realtime notifications of changes to listings available to your account, we require a URL of the form `api.mycompany.com/foyerNotify` that accepts a query parameter of `listing=`[`https://api.foyer.ai/odata/Property('ListingKey')`](https://api.foyer.ai/odata/Property\('ListingKey'\))`.`The URL provided to your system in the query parameter can then be used to make a network request back to our server for the listing data in standard RESO format.&#x20;

{% hint style="warning" %}
Make sure to include your valid authorization token in the request header when querying our Property endpoint. See Authorization in the sidebar for more details
{% endhint %}

You can provide your notification URL during sign-up as the `notify` body parameter or at a later time using the `updateNotify` endpoint outlined below.

## Publisher Sign Up

<mark style="color:green;">`POST`</mark> `https://api.foyer.ai/User/publisherSignUp`

This method is used for a publisher to sign up to receive syndication notifications. This method returns an authorization token in the response header. Additional tokens can be generated by using the login method, see Authorization in the sidebar for more details.

#### Request Body

| Name            | Type   | Description                                                             |
| --------------- | ------ | ----------------------------------------------------------------------- |
| email           | string | The email to be associated with the account                             |
| password        | string | The password used for authorization                                     |
| confirmPassword | string | The password again for confirmation                                     |
| notify          | string | The url for receiving notifications about changes to available listings |
| website         | string | A website for the organization associated with the account              |
| logo            | string | An image url for the organization associated with the account           |

{% tabs %}
{% tab title="200 The authentication token will be present in the response header" %}

```
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Be sure to save the authorization token in the response header and include it when making API requests.
{% endhint %}

## Publisher Update Notification URL

<mark style="color:green;">`POST`</mark> `https://api.foyer.ai/Publisher/updateNotify`

This method is used to update the push notification URL for your account. A valid authorization token is needed to make sure the correct account is updated.

#### Headers

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| Authorization | string | Authorization token |

#### Request Body

| Name   | Type   | Description                                                             |
| ------ | ------ | ----------------------------------------------------------------------- |
| notify | string | The url for receiving notifications about changes to available listings |

{% tabs %}
{% tab title="200 The request was successful and push notifications will now be directed to the provided URL" %}

```
```

{% endtab %}
{% endtabs %}

## Get a listing in RESO format

<mark style="color:blue;">`GET`</mark> `https://api.foyer.ai/odata/Property('ListingKey')`

This endpoint allows you to receive all listing details in standard RESO format

#### Path Parameters

| Name     | Type   | Description                |
| -------- | ------ | -------------------------- |
| reportId | string | id for the desired listing |

#### Headers

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| Authorization | string | Authorization token |

{% tabs %}
{% tab title="200 Listing successfully exported. Example below is not an exhaustive list of available fields" %}

```
{
  "ListingKey": "3yd-A2SELL-281884",
  "ListingId": "281884",
  "PropertyType": "Land",
  "PropertySubType": "Other",
  "ListPrice": 21900,
  ...
  "Media": [
    {
      "MediaCategory": "Photo",
      "MediaURL": "http://photos.listhub.net/A2SELL/281884/1", // required
      "MediaKey": "2483763c0011d2a36483fb3f28ca8c00564abb4d",
      "MediaModificationTimestamp": "2019-10-03T09:14:00.000Z"
    },
    ...
  ]
}
```

{% endtab %}

{% tab title="401 When no valid authorization header is present " %}

```
{
    "statusCode":401,
    "error":"Unauthorized",
    "message":"Missing authentication"
}
```

{% endtab %}

{% tab title="403 When valid header is present but account does not have read permission for this listing" %}

```
{
    "statusCode": 403,
    "error": "Forbidden",
    "message": "Forbidden"
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
See the [Data Dictionary](https://ddwiki.reso.org/display/DDW17/Introduction) for more information on RESO format
{% endhint %}

## Refresh all listings

<mark style="color:blue;">`GET`</mark> `https://api.foyer.ai/Publisher/refreshAllProperties`

This method is used for receiving an array of exportReso urls that can be used to update all listings available for one's own account.&#x20;

#### Headers

| Name          | Type   | Description         |
| ------------- | ------ | ------------------- |
| Authorization | string | Authorization token |

{% tabs %}
{% tab title="200 " %}

```
[
    "https://api.foyer.ai/reports/1/exportReso"
    "https://api.foyer.ai/reports/2/exportReso"
]
```

{% endtab %}
{% endtabs %}
