How to use GitHub Actions with webhooks & API endpoints

Ralph J. Smit Laravel Software Engineer

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 a webhook"
- '**'
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 better, feel free to leave a comment below and I'll credit you if I add it.✌️🚀👇

Published by Ralph J. Smit on in Github . Last updated on 28 March 2022 .