PlandalfDocsSign inStart free trial

API and webhooks

Links

A link connects a Plandalf price to something in your system that the price grants, such as a MemberPress membership. Plandalf includes the link on every invoice line in webhooks, so your system knows what to grant. Send a snapshot of your object's billing terms and each link reports drift: the fields where your object and the Plandalf price disagree.

Example

curl -X POST https://admin.plandalf.dev/api/v1/links \
  -H "Authorization: Bearer $PLANDALF_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "price_id": 1,
    "system": "memberpress",
    "site": "members.example.com",
    "external_type": "membership",
    "external_id": "123",
    "external_name": "Gold membership",
    "external_url": "https://members.example.com/wp-admin/post.php?post=123",
    "snapshot": { "amount_cents": 4900, "currency": "usd", "interval": "month", "interval_count": 1 }
  }'

A new link returns 201; the same price, system, site and object again updates it and returns 200. When the membership changes on your side, call POST /api/v1/links/refresh with the same system, site, external_type and external_id and a new snapshot.

Endpoints

GET /api/v1/links

Links in creation order, up to 500, filtered by any of system, site, external_type, external_id and price_id. Each link carries drift: the fields where your snapshot and the Plandalf price disagree.

Parameters

NameInTypeWhat it is
system optionalquerystring | null
site optionalquerystring | null
external_type optionalquerystring | null
external_id optionalquerystring | null
price_id optionalqueryinteger | null
curl https://admin.plandalf.dev/api/v1/links \
  -H "Authorization: Bearer $PLANDALF_API_KEY"

Response

{
  "data": [
    {
      "id": 0,
      "system": "string",
      "site": "string",
      "external_type": "string",
      "external_id": "string",
      "external_name": "string",
      "external_url": "string",
      "role": "string",
      "price": {
        "id": 0,
        "lookup_key": "string",
        "name": "string",
        "product": {
          "id": 0,
          "name": "string",
          "lookup_key": "string"
        },
        "amount_cents": 0,
        "currency": "string",
        "recurring": {
          "interval": "string",
          "interval_count": 0
        },
        "trial_period_days": 0,
        "active": true
      },
      "snapshot": {
        "amount_cents": 0,
        "currency": "string",
        "interval": "string",
        "interval_count": 0,
        "trial_period_days": 0
      },
      "drift": [
        {
          "field": "string",
          "plandalf": null,
          "external": null
        }
      ],
      "drift_acknowledged": true,
      "updated_at": "string"
    }
  ]
}

Errors

StatusWhen
401The API key or OAuth token is missing or invalid.
422The request failed validation; errors lists the problems by field.

Create or update a link

POST /api/v1/links

Connects a Plandalf price to an object in your system. Upserts by price, system, site, external_type and external_id; returns 201 for a new link and 200 for an update. Send a snapshot of your object's billing terms so Plandalf can report drift.

Body

FieldTypeWhat it is
systemstring
sitestring
external_typestring
external_idstring
external_name optionalstring | null
external_url optionalstring | null
price_idinteger
role optional"grants"
snapshot optionalobject
curl -X POST https://admin.plandalf.dev/api/v1/links \
  -H "Authorization: Bearer $PLANDALF_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"system":"string","site":"string","external_type":"string","external_id":"string","external_name":"string","external_url":"string","price_id":0,"role":"grants","snapshot":{"amount_cents":0,"currency":"string","interval":"day","interval_count":0,"trial_period_days":0}}'

Response

{
  "id": 0,
  "system": "string",
  "site": "string",
  "external_type": "string",
  "external_id": "string",
  "external_name": "string",
  "external_url": "string",
  "role": "string",
  "price": {
    "id": 0,
    "lookup_key": "string",
    "name": "string",
    "product": {
      "id": 0,
      "name": "string",
      "lookup_key": "string"
    },
    "amount_cents": 0,
    "currency": "string",
    "recurring": {
      "interval": "string",
      "interval_count": 0
    },
    "trial_period_days": 0,
    "active": true
  },
  "snapshot": {
    "amount_cents": 0,
    "currency": "string",
    "interval": "string",
    "interval_count": 0,
    "trial_period_days": 0
  },
  "drift": [
    {
      "field": "string",
      "plandalf": null,
      "external": null
    }
  ],
  "drift_acknowledged": true,
  "updated_at": "string"
}

Errors

StatusWhen
401The API key or OAuth token is missing or invalid.
403The credentials are valid but not allowed here: a site-connection token outside its scope, or the organization can't make this request.
422The request failed validation; errors lists the problems by field.

Refresh links to one of your objects

POST /api/v1/links/refresh

Call it when your object changes (for example the membership was edited): updates the name, URL and snapshot on every link to it, so drift is current. Returns the updated links.

Body

FieldTypeWhat it is
systemstring
sitestring
external_typestring
external_idstring
external_name optionalstring | null
external_url optionalstring | null
snapshot optionalobject
curl -X POST https://admin.plandalf.dev/api/v1/links/refresh \
  -H "Authorization: Bearer $PLANDALF_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"system":"string","site":"string","external_type":"string","external_id":"string","external_name":"string","external_url":"string","snapshot":{"amount_cents":0,"currency":"string","interval":"day","interval_count":0,"trial_period_days":0}}'

Response

{
  "data": [
    {
      "id": 0,
      "system": "string",
      "site": "string",
      "external_type": "string",
      "external_id": "string",
      "external_name": "string",
      "external_url": "string",
      "role": "string",
      "price": {
        "id": 0,
        "lookup_key": "string",
        "name": "string",
        "product": {
          "id": 0,
          "name": "string",
          "lookup_key": "string"
        },
        "amount_cents": 0,
        "currency": "string",
        "recurring": {
          "interval": "string",
          "interval_count": 0
        },
        "trial_period_days": 0,
        "active": true
      },
      "snapshot": {
        "amount_cents": 0,
        "currency": "string",
        "interval": "string",
        "interval_count": 0,
        "trial_period_days": 0
      },
      "drift": [
        {
          "field": "string",
          "plandalf": null,
          "external": null
        }
      ],
      "drift_acknowledged": true,
      "updated_at": "string"
    }
  ]
}

Errors

StatusWhen
401The API key or OAuth token is missing or invalid.
403The credentials are valid but not allowed here: a site-connection token outside its scope, or the organization can't make this request.
422The request failed validation; errors lists the problems by field.

Acknowledge a link's drift

POST /api/v1/links/{link}/acknowledge

Keeps the current difference on purpose (for example a promotional Plandalf price), so drift_acknowledged is true until the drift changes again.

Parameters

NameInTypeWhat it is
linkpathinteger
curl -X POST https://admin.plandalf.dev/api/v1/links/:link/acknowledge \
  -H "Authorization: Bearer $PLANDALF_API_KEY"

Response

{
  "id": 0,
  "system": "string",
  "site": "string",
  "external_type": "string",
  "external_id": "string",
  "external_name": "string",
  "external_url": "string",
  "role": "string",
  "price": {
    "id": 0,
    "lookup_key": "string",
    "name": "string",
    "product": {
      "id": 0,
      "name": "string",
      "lookup_key": "string"
    },
    "amount_cents": 0,
    "currency": "string",
    "recurring": {
      "interval": "string",
      "interval_count": 0
    },
    "trial_period_days": 0,
    "active": true
  },
  "snapshot": {
    "amount_cents": 0,
    "currency": "string",
    "interval": "string",
    "interval_count": 0,
    "trial_period_days": 0
  },
  "drift": [
    {
      "field": "string",
      "plandalf": null,
      "external": null
    }
  ],
  "drift_acknowledged": true,
  "updated_at": "string"
}

Errors

StatusWhen
401The API key or OAuth token is missing or invalid.

DELETE /api/v1/links/{link}

Removes the link between the price and your object. The price itself is unchanged.

Parameters

NameInTypeWhat it is
linkpathinteger
curl -X DELETE https://admin.plandalf.dev/api/v1/links/:link \
  -H "Authorization: Bearer $PLANDALF_API_KEY"

Response

{
  "id": 0,
  "deleted": true
}

Errors

StatusWhen
401The API key or OAuth token is missing or invalid.