Add a new subscription#
Core action
This is a required action. All server implementations must support it.
POST /subscriptions
This endpoint enables clients to add new subscriptions to the system for the authenticated user. It returns an array of success
responses for newly added subscriptions, and an array of failure
responses for subscriptions that couldn’t be added.
Field |
Type |
Required? |
Description |
---|---|---|---|
|
String |
Yes |
The URL of the podcast RSS feed. |
|
String |
Yes |
The globally unique ID of the podcast |
|
Boolean |
Yes |
Whether the user is subscribed to the podcast or not |
|
Datetime |
Yes |
The date on which the |
Field |
Type |
Required? |
Description |
---|---|---|---|
|
String |
Yes |
The URL of the podcast RSS feed |
|
String |
Yes |
A message explaining why the subscription couldn’t be added |
Request parameters#
The client must provide a list of objects containing the following parameters:
Field |
Type |
Required? |
Description |
---|---|---|---|
|
String |
Yes |
The URL of the podcast RSS feed. The client must provide a protocol (for example: |
|
String |
No |
The GUID found in the podcast RSS feed |
Important
If a client passes a guid
this is treated as authoritative by the server. The client may pass a guid
only if it is parsed from the podcast RSS feed.
{
"subscriptions": [
{
"feed_url": "https://example.com/rss1"
},
{
"feed_url": "https://example.com/rss2"
},
{
"feed_url": "https://example.com/rss3"
},
{
"feed_url": "https://example.com/rss4",
"guid": "2d8bb39b-8d34-48d4-b223-a0d01eb27d71"
}
]
}
<?xml version="1.0" encoding="UTF-8"?>
<subscriptions>
<subscription>
<feed_url>https://example.com/feed1</feed_url>
</subscription>
<subscription>
<feed_url>https://example.com/feed2</feed_url>
</subscription>
<subscription>
<feed_url>https://example.com/feed3</feed_url>
</subscription>
<subscription>
<feed_url>https://example.com/feed4</feed_url>
<guid>2d8bb39b-8d34-48d4-b223-a0d01eb27d71</guid>
</subscription>
</subscriptions>
Server-side behavior#
When new feeds are posted to the server, the server must return a success response to the client immediately to acknowledge the request. To ensure that data can be returned immediately, the following flow must be followed:
The client sends a payload to the server
For each object in the payload, the server does the following:
Checks if there’s a
guid
entry in the payloadIf a
guid
is present, the server stores theguid
for later useIf no
guid
is present, the server generates aguid
for later use
Checks to see if there is an existing entry with the same
guid
orfeed_url
If an existing entry is found, the server sets the
is_subscribed
field totrue
and updates thesubscription_changed
date to the current date. If thedeleted
field is populated, the field is set toNULL
to show that the subscription is activeIf no existing entry is found, the server creates a new subscription entry
The server returns a success payload containing the subscription information for each object in the request payload.
Subscription GUID update#
If the client doesn’t send a guid
in the subscription payload, the server must create one immediately to ensure the following:
Each entry has an associated
guid
The client receives a success response as quickly as possible
Once this is done, the server should asynchronously verify that there isn’t a more authoritative GUID available. The following flow should be used:
The server fetches and parses the RSS feed to search for a
guid
field in thepodcast
namespace.If a more authoritative
guid
is found, the server must update the subscription entry as follows:Create a new subscription entry with the new
guid
Update the
new_guid
field in the existing entry to point to the newguid
Update the
guid_changed
field in the existing entry to the current date
Example request#
curl --location '/subscriptions' \
--header 'Content-Type: application/json' \
--data '{
"subscriptions": [
{
"feed_url": "https://example.com/feed1"
},
{
"feed_url": "https://example.com/feed2"
},
{
"feed_url": "https://example.com/feed3"
},
{
"feed_url": "example.com/feed4",
"guid": "2d8bb39b-8d34-48d4-b223-a0d01eb27d71"
}
]
}'
curl --location '/subscriptions' \
--header 'Content-Type: application/xml' \
--data '<?xml version="1.0" encoding="UTF-8"?>
<subscriptions>
<subscription>
<feed_url>https://example.com/feed1</feed_url>
</subscription>
<subscription>
<feed_url>https://example.com/feed2</feed_url>
</subscription>
<subscription>
<feed_url>https://example.com/feed3</feed_url>
</subscription>
<subscription>
<feed_url>example.com/feed4</feed_url>
<guid>2d8bb39b-8d34-48d4-b223-a0d01eb27d71</guid>
</subscription>
</subscriptions>'
Example 200 response#
{
"success": [
{
"feed_url": "https://example.com/rss1",
"guid": "8d1f8f09-4f50-4327-9a63-639bfb1cbd98",
"is_subscribed": true,
"subscription_changed": "2023-02-23T14:00:00.000Z"
},
{
"feed_url": "https://example.com/rss2",
"guid": "968cb508-803c-493c-8ff2-9e397dadb83c",
"is_subscribed": true,
"subscription_changed": "2023-02-23T14:00:00.000Z"
},
{
"feed_url": "https://example.com/rss3",
"guid": "e672c1f4-230d-4ab4-99d3-390a9f835ec1",
"is_subscribed": true,
"subscription_changed": "2023-02-23T14:00:00.000Z"
}
],
"failure": [
{
"feed_url": "example.com/rss4",
"message": "No protocol present"
}
]
}
<?xml version="1.0" encoding="UTF-8"?>
<subscriptions>
<success>
<feed_url>https://example.com/rss1</feed_url>
<guid>8d1f8f09-4f50-4327-9a63-639bfb1cbd98</guid>
<is_subscribed>true</is_subscribed>
<subscription_changed>2023-02-23T14:00:00.000Z</subscription_changed>
</success>
<success>
<feed_url>https://example.com/rss2</feed_url>
<guid>968cb508-803c-493c-8ff2-9e397dadb83c</guid>
<is_subscribed>true</is_subscribed>
<subscription_changed>2023-02-23T14:00:00.000Z</subscription_changed>
</success>
<success>
<feed_url>https://example.com/rss3</feed_url>
<guid>e672c1f4-230d-4ab4-99d3-390a9f835ec1</guid>
<is_subscribed>true</is_subscribed>
<subscription_changed>2023-02-23T14:00:00.000Z</subscription_changed>
</success>
<failure>
<feed_url>example.com/rss4</feed_url>
<message>No protocol present</message>
</failure>
</subscriptions>