Shift API

Shift now offers an API for users subscribing to a Shifty Plan. The Shift API allows you to trigger Shifts to run against your Laravel applications by using a traditional HTTP API or webhooks.

HTTP API

Each Shifty Plan provides access to the /api/run endpoint. Using this endpoint you can trigger Shifts to run as part of your build, a weekly audit, or on-demand.

Currently the Shift API allows you to run the follow Shifts:

To run a Shift, send a POST request to https://laravelshift.com/api/run with the following data:

  • api_token Your Shifty Plan API token
  • code The code of the Shift you wish to run. For example:
    • 60 for the Laravel 6.0 Shift
    • LL for the Laravel Linter
    • LF for the Laravel Fixer
    • DU for the Dependency Updater
    • P2 for the PSR-2
  • scs The Git service, repository, and branch name as a colon (:) delimited connection string. For example:
    • github:laravel-shift/bot:master
    • bitbucket:pureconcepts/workshops:develop
    • gitlab:jasonmccreary/blog:feature-branch

The following is an example API request using curl to run the Laravel Fixer against the master branch of the jasonmccreary/confidentlaravel.com repository on GitHub. You may use this example by substituting the request data with your own API Key and values.

curl -X POST -H 'Accept: application/json' \
    -d "api_token=1234567890" \
    -d "code=60" \
    -d "scs=github:jasonmccreary/gettinggit.com:master" \
    https://laravelshift.com/api/run

Webhooks

You may also setup webhooks which can be triggered when certain repository events occur. Each Shifty Plan allows you to setup a webhook to run a customizable version of the Laravel Fixer anytime you open a Pull Request.

To do so, you may register a webhook for any repository included under your plan with the following details:

  • Set the webhook URL to your Shifty Plan endpoint, for example: https://laravelshift.com/api/webhook/1234567890
  • Ensure the payload is sent as application/json
  • Under Events, only check the Pull Request event (Merge Request for GitLab)

For additional details on registering a webhook for your repository, review the specific documentation for GitHub, Bitbucket, or GitLab.