How to use GitHub Actions with webhooks & API endpoints

Published April 23, 2021; last updated on September 10, 2021
How to use GitHub Actions with webhooks & API endpoints

GitHub Actions is a great tool for every developer. It can be easily incorporated in your development workflow. Sometimes you’d need to visit a certain endpoint, for example in a REST API. Luckily, this is very easy with GitHub Actions. In this tutorial I’ll show you how to use curl to visit API endpoints.

First, what is curl? Curl (or cURL) is a tool for getting data from a URL and transferring data to it. It effectively allows you to call a URL from the terminal and display the data returned using one of the HTTP methods.

Skip the explanation and go immediately to the GitHub Actions part.

HTTP methods

If you already know what methods are with RESTful APIs or why this

There are five methods to call a REST API: GET, POST, PUT, PATCH, and DELETE. A method gives information about what someone wants to do with a certain URL. For example, GET means that request information. POST means that you have new information and want to add it.

For example, say you have an API at The same URL can be used to get an image (request) and to add a new image. It would look like this:

  • GET – get a certain image
  • POST – add a certain image

(Most likely you’ll also need to provide an image ID or an image URL, but that’s not important for understand methods.)

Trying a GET method

Curl can be used from the command line. Let’s try it. Run:


If you scroll up, you might see that you’ve now gotten the HTML of my website homepage. This is also how a browser works.

Making a Curl request

There are many options for curl, but there is one important one – -X. This parameter defines the method to use for the request. The syntax looks like this:

curl -X GET

With the parameter -X, you specify the method (e.g. -X POST or -X PUT).

curl -X GET
curl -X POST
curl -X PUT
curl -X PATCH
curl -X DELETE

As you see, with curl you can hit up any API endpoint or webhook!

Using curl with GitHub Actions

It is very easy to use curl. It is already a tool on the command line and GitHub allows you to run CLI commands from GitHub Actions.

A GitHub Actions workflow generally looks something like this:

name: Hit up a Webhooks

      - '**'

    runs-on: ubuntu-latest
    - name: REST API with curl
      run: |
        curl -X GET ""

Especially the last part is important: the run. Here you can add your curl command or your endpoint.

  1. First, test your curl command on your own terminal or command line interface (CLI).
  2. Add it to your GitHub Actions.

Wrapping up

As you see, it is ridiculously easy to hit up an API or endpoint with curl in GitHub Actions. It’s as simple as running a simple command ánd it can easily be tested! If you have a suggestion to make the article, feel free to leave a comment below and I’ll credit you if I implement it ✌️🚀👇

Stay up to date with all things Laravel, Tailwind, WordPress & PHP

Subscribe now to my e-mail newsletter and get my latest articles and project updates delivered directly to your inbox. Never miss an update.

Image Ralph J. Smit
Ralph is a designer gone developer. He happily lives in the Netherlands. His passion for good design drove him towards development, because he felt that no-code tools were too limiting. On this blog, Ralph writes the articles he would've wanted to have during his continual developer journey. → Follow on Twitter


Leave a reply

Your email address will not be published. Required fields are marked *

Do you want more articles like this delivered straight to your inbox?

Subscribe now to my e-mail newsletter and get my latest articles and project updates delivered directly to your inbox. Never miss an update.