Leanpub lets you use webhooks to trigger a preview or a publish event whenever you push to your Git repository if you're writing your book using our Bitbucket writing mode.

First, go to the Webhooks page for your book here:


...making sure to replace YOUR_BOOK with your book's unique web address.

You can also navigate to this page from your book's Overview page, by clicking the Webhooks link in the Help section.

On that page, you'll find the Payload URLs you will need to copy into Bitbucket. There is a different Payload URL for previewing and publishing.

The top Payload URL is the one you will use if you want to trigger a preview every time you push to your repository; the bottom Payload URL is the on you will use if you want to publish a new version of your book every time you push to your repository.

NOTE: Do NOT show your API key to anyone! Treat it like a password.

Select the URL you want to use and copy it.

Next, on Bitbucket, go to the repository for your book and click on "Repository settings":

Next, select "Webhooks":

This will take you to the Webhooks page for your repository. Now, click on "Add webhook":

Give your webhook a title:

Next, paste the Payload URL you copied earlier into the "URL" box:

(We've blurred out the actual API key again in this example.)

Next, click the "Save" button:

You will now see that the webhook has been added to your repository:

That's it! The next time you push to your repository, that will trigger a preview of your book, or publish a new version of your book, depending on which option you chose. Please note that it may take a moment or two before you see the progress bar, indicating that the book generation process is under way.

Did this answer your question?