Shift with red gradient lettering

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. You may also make calls to the HTTP API to add or remove repositories on your Shifty Plan.

HTTP API

While you may use the web UI, Shift definitely understands the desire to automate common tasks. As such, Shift offers an HTTP API for you to do so. All calls to the HTTP API must be authenticated. You may do so by passing your your Shifty Plan API token which was included in your welcome email. If you no longer have it, you may email support to have it reset.

Run a Shift

You may call the /api/run endpoint to run a Shift as part of your build, a weekly audit, or on-demand. Currently, you may run the following 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:
    • 11 for the Laravel 11.x Shift
    • 10 for the Laravel 10.x Shift
    • LL for the Laravel Linter
    • LF for the Laravel Fixer
    • DU for the Dependency Upgrader
    • CF for the Code Formatter
  • 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/gettinggit.com repository on GitHub.

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

Want to quickly convert this curl command to an Http call within your Laravel applications? Check out Shift's free curl to HTTP online converter.

List all repositories

To list all repositories on your Shifty Plan, send a GET request to https://laravelshift.com/api/repository and include your Shifty Plan api_token in the header of the request.

The following is an example API request using curl to retrieve a list of your Shifty Plan repositories. You may use this example by substituting the Bearer header value with your own API Key.

curl -H 'Accept: application/json' \
    -H "Authorization: Bearer 1234567890" \
    https://laravelshift.com/api/repository

Add a repository

To add a repository to your Shifty Plan, send a POST request to https://laravelshift.com/api/repository with the following data:

  • api_token Your Shifty Plan API token
  • service The Git service where the repository is hosted. For example: GitHub, Bitbucket, or GitLab
  • repository The repository. For example: jasonmccreary/baselaravel.com
  • branch The default source branch to use. For example: main, master, develop
  • automation A boolean to enable or disable automation. This is optional and disabled by default.

The following is an example API request using curl to add the jasonmccreary/baselaravel.com repository on GitHub with a default branch of main to a Shifty Plan and enable automation. 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 "service=GitHub" \
    -d "repository=github:jasonmccreary/baselaravel.com" \
    -d "branch=main" \
    -d "automation=1"
    https://laravelshift.com/api/repository

Remove a repository

To remove a repository from your Shifty Plan, send a DELETE request to https://laravelshift.com/api/repository with the following data:

  • api_token Your Shifty Plan API token
  • service The Git service where the repository is hosted. For example: GitHub, Bitbucket, or GitLab
  • repository The repository. For example: jasonmccreary/confidentlaravel.com

The following is an example API request using curl to remove the jasonmccreary/confidentlaravel.com repository on GitHub from a Shifty Plan. You may use this example by substituting the request data with your own API Key and values.

curl -X DELETE -H 'Accept: application/json' \
    -d "api_token=1234567890" \
    -d "service=GitHub" \
    -d "repository=github:jasonmccreary/confidentlaravel.com"
    https://laravelshift.com/api/repository

Webhooks

Each Shifty Plan allows you to set up webhooks to perform an automated code review of your changes by running the Laravel Fixer or custom set of tasks anytime you open a PR.

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.

Sign in with any of the following services to connect Shift with your Laravel project.


Don't use one of these services?

Temporarily push your project to a free, private repository on one of these cloud-based services or upgrade your project locally with Shift for Docker.