Skip to main content

Plans API Reference

Overview

The Plans API enables developers to programmatically create and manage plans on the Publica.la store. This API is designed for store administrators and integration partners who need to automate plan creation and management.

info

Make sure you generated the api_token on your store. More info in the API Authentication guide

Endpoint Reference

EndpointMethodDescription
/integration-api/v1/dashboard/plansPOSTCreate a new plan
/integration-api/v1/dashboard/plansGETRetrieve plans (with optional filtering)
/integration-api/v1/dashboard/plans/(plan_id)PUTUpdate an existing plan
/integration-api/v1/dashboard/plans/collectionsGETGet available collections for plans

Create a Plan

Create a new plan on your store.

Endpoint: POST /integration-api/v1/dashboard/plans

Request Body

ParameterTypeDescription
typestringPlan type, either recurring or prepaid
namestringDisplay name of the plan
detailsstringHTML description of the plan
durationinteger, nullableDuration in months (required for prepaid plans, null for recurring)
recommendedbooleanWhether to mark this plan as recommended
privatebooleanWhether this plan is private (accessible only via direct link)
assigns_collectionsbooleanWhether this plan is associated with specific collections
concurrency_limitintegerMaximum number of concurrent sessions allowed
collectionsarrayList of collection names to assign to this plan
download_filesbooleanWhether to allow content downloads on this plan
pricesobjectPrice mapping by currency code (amount in cents)
free_trialbooleanWhether this plan offers a free trial
free_trial_daysintegerNumber of free trial days (required if free_trial is true)

Example Request

{
"type":"recurring",
"name":"Demo Plan",
"details":"<div><!--block-->This is the description of the Demo Plan</div>",
"duration":null,
"recommended":true,
"private":false,
"assigns_collections":true,
"concurrency_limit":"1",
"collections":[
"Prepaid"
],
"download_files":false,
"prices":{
"ARS":0,
"USD":"1",
"EUR":0,
"MXN":"1",
"COP":0,
"PEN":0,
"CLP":0,
"AUD":0,
"UYU":0,
"BOB":0,
"PYG":0,
"BRL":0,
"INR":0,
"GTQ":0,
"HNL":0
},
"free_trial":true,
"free_trial_days":"15"
}

Response Codes

CodeDescription
201Plan created successfully
422Validation error (details in response)
401Unauthorized (invalid API token)

Assigning Collections

To get available collections for assignment to plans:

Endpoint: GET /integration-api/v1/dashboard/plans/collections

Example Response

{
"CODE": "success",
"data": [
"Collection 1",
"Testing Collection 2",
"Demo Collection",
"Most Recent",
"Most Read",
"For Children"
]
}

Retrieve Plans

Get a list of plans with optional filtering.

Endpoint: GET /integration-api/v1/dashboard/plans/

Query Parameters

ParameterTypeDescriptionExample
querystringSearch term to filter plans?query='Premium'
tip

The query parameter searches across plan name, type, and description fields.

Example Response

{
"CODE": "success",
"data": {
"assigns_collections": true,
"collections": ["Demo Collection 1", "Demo Collection 2"],
"concurrency_limit": 1,
"created_at": "2021-05-21 15:34:36",
"customer": null,
"deleted_at": null,
"details": "This is a plan for educational purposes",
"download_files": 0,
"duration": 12,
"free_trial": 0,
"free_trial_days": 0,
"has_geolocalized_prices": false,
"id": 2696,
"name": "Test Plan Name",
"prices": [],
"private": 1,
"recommended": false,
"type": "prepaid",
"updated_at": "2021-05-21 15:34:36",
"url": "https://example.publica.la/subscribe/2696?signature={random_hash}"
}
}

Response Codes

CodeDescription
200Success
404Object not found
401Unauthorized (invalid API token)

Update a Plan

Update an existing plan by ID.

Endpoint: PUT /integration-api/v1/dashboard/plans/\(plan_id)

Request Body

Same parameters as the Create endpoint, plus:

ParameterTypeDescription
customerstringCustomer information for external plans
invoicestringInvoice reference for external plans
file_namestringName of file attachment
upload_filefileFile attachment for the plan

Example Request

{
"type":"recurring",
"name":"Updated Demo Plan",
"details":"<div><!--block-->This is the updated description</div>",
"duration":null,
"recommended":true,
"private":false,
"assigns_collections":true,
"concurrency_limit":"1",
"collections":[
"Prepaid"
],
"download_files":false,
"customer":"",
"invoice":"",
"file_name":"",
"upload_file":false,
"prices":{
"ARS":0,
"USD":"1",
"EUR":0,
"MXN":"1"
},
"free_trial":true,
"free_trial_days":"15"
}

Response Codes

CodeDescription
204Plan updated successfully
422Validation error (details in response)
404Plan not found
401Unauthorized (invalid API token)

Common Error Scenarios

ErrorDescriptionSolution
Invalid collection nameCollection specified in request doesn't existUse the /collections endpoint to get valid names
Invalid plan typePlan type must be 'recurring' or 'prepaid'Check value of type parameter
Missing durationPrepaid plans require a duration valueAdd duration parameter for prepaid plans
Pricing errorCurrency codes or amounts are invalidEnsure all currency values are valid

Integration Best Practices

  1. Validate collections before creating plans by calling the collections endpoint
  2. Set appropriate concurrency limits based on your business model
  3. Consider plan privacy - use private plans for special offers
  4. Test free trials thoroughly before deploying to production
X

Graph View