Skip to main content

Read and add an episode’s production notes through Podcast Workflow’s REST routes

Premium Intermediate Podcast Workflow

GET and POST /benecaster-podcast-workflow/v1/shows/{show_id}/episodes/{episode_id}/notes.

These are Benecaster’s episode notes, read with benecaster_get_episode_notes() and written with benecaster_add_episode_note(). There is no second store, and Benecaster’s benecaster_episode_note_added action is the hook for a new note (Podcast Workflow fires none of its own). PHP code should call the two functions directly. These routes add the Workbench’s per-show checks, as Read the Podcast Workflow Workbench over REST describes: benecaster_rest_permission_admin, then 404 benecaster_podcast_workflow_show_not_found, 403 benecaster_podcast_workflow_off_for_show, 404 benecaster_podcast_workflow_episode_not_found and 409 benecaster_podcast_workflow_other_show.

  • GET …/notes answers { notes: [note] }, newest first, up to Benecaster’s default of 100. A note is { id, content, type, author_name, created_at, created_label }: type is system or internal; author_name is the author’s display name or null; created_at is UTC Y-m-d H:i:s; created_label is that instant in the site’s date and time format and time zone.
  • POST …/notes sends { content }, plain text through sanitize_textarea_field() (tags stripped, line breaks kept), up to 10,000 characters. It adds an internal note by the signed-in user and answers 201 with the refreshed list. Empty is 400 benecaster_podcast_workflow_note_empty; too long is 400 benecaster_podcast_workflow_note_too_long.

On a Benecaster version without the two functions, both routes answer 501 benecaster_podcast_workflow_notes_unavailable.

Code

<?php
$request = new WP_REST_Request( 'POST', '/benecaster-podcast-workflow/v1/shows/42/episodes/1234/notes' );
$request->set_body_params( [ 'content' => "Guest asked to cut the bit about the dog.\nKeep the outro." ] );
$notes = rest_do_request( $request )->get_data()['notes'];

View on GitHub →

Need this built rather than just documented? See our services →