Skip to content

Plenty

service_jtl — Endpoints: Plenty

Endpoints to manage Plenty credentials and to run bundle cleanup operations that may coordinate with JTL.

Credential management

  • POST /credentials/ — Create a Plenty credential. Body model: PlentyCredentialsCreate (username, password, plenty_id, active_jtl, active).

Example body:

{
  "username": "plenty_user",
  "password": "secret",
  "plenty_id": 906,
  "active_jtl": true,
  "active": true
}
  • GET /credentials/ — List Plenty credentials.
  • PUT /credentials/{credential_id} — Update credential metadata (PlentyCredentialsUpdate).
  • DELETE /credentials/{credential_id} — Delete a credential.
  • POST /credentials/{credential_id}/toggle-active — Toggle active status.
  • POST /credentials/test — Test a Plenty credential using PlentyCredentialTestRequest (username, password, plenty_id); returns simple success/valid flag.

Bundle cleanup

  • POST /clean-up-bundles — Run the bundle cleanup process. High-level steps:
  • Fetch active Plenty credentials and bundle items (Plenty_Manager.get_items(is_bundle=True)).
  • Resolve referrers/market IDs and compute target markets for deletion.
  • Batch-delete variation markets and optionally delete SKUs from JTL if stock is zero.
  • Write intermediate payloads (skus_to_delete_payloads.json) and create notifications for items that couldn't be deleted.

Example response (success):

{
  "status": "success",
  "bundles_found": 3,
  "deleted_markets_count": 12,
  "deleted_skus_count": 8
}
  • GET /system-status — Quick readiness check requiring active JTL + Plenty credentials.

Cron endpoints

  • POST /cron/start, POST /cron/stop, GET /cron/status — Schedule/stop and inspect the bundle cleanup job via CronJobManager.

Implementation

Operational notes

  • The cleanup operation is I/O intensive and interacts with both Plenty and JTL APIs. The service uses async HTTP client httpx.AsyncClient with retry/backoff and honours Retry-After headers.
  • Configure plenty_id and ensure the Plenty API credentials have required permissions for batch operations.