Glossary
Last Updated Jul 25, 2023

Payload

Emma Jagger

Table of Contents:

Get your free
API key now
4.8 from 1,863 votes
See why the best developers build on Abstract
START FOR FREE
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
No credit card required

What is a Payload?

In APIs, the payload is the data contained within a request. The description is borrowed from the transportation industry, where a truck carries its cargo (its "payload") to a location. The truck, as with the API request, is always the same (the "overhead" that delivers the payload), but the payload changes with each request.

API Payload examples

Different requests carry different payloads, but there is some standardization within their delivery. The payload within a request is usually delineated with curly braces `{}`, and the request is usually sent as a JSON file. JSON stands for JavaScript Object Notation, and is an alternative to XML. JSON is more lightweight than XML, so it's a more efficient method of on-demand data exchange.  Let's try a few examples using Abtract's Email Validation API.

GET Request Payload

`curl 'https://emailvalidation.abstractapi.com/v1/?api_key=[Your API key]&email=[youremail@address.com]'` will use cURL to validate an email and return the payload you requested with your GET request. If you inspect this response, you will see payload fields:


{
    "email": "youremail@gmail.com",
    "autocorrect": "",
    "deliverability": "DELIVERABLE",
    "quality_score": "0.70",
    "is_valid_format": {
        "value": true,
        "text": "TRUE"
    },
    "is_free_email": {
        "value": true,
        "text": "TRUE"
    },
    "is_disposable_email": {
        "value": false,
        "text": "FALSE"
    },
    "is_role_email": {
        "value": false,
        "text": "FALSE"
    },
    "is_catchall_email": {
        "value": false,
        "text": "FALSE"
    },
    "is_mx_found": {
        "value": true,
        "text": "TRUE"
    },
    "is_smtp_valid": {
        "value": true,
        "text": "TRUE"
    }
}

So, all of the other information required to make this GET request possible, like authentication, headers, etc., is not important to us. We just want the information we requested.  

POST Request Payload

What about going the other direction, and posting a payload of our own to a server? They say that building something yourself teaches you how it works, so let's give it a try.


curl -X POST https://reqbin.com/echo/post/json # Post request to address
   -H "Content-Type: application/json" # Defines payload format
   -d "{\"login\":\"my_login\",\"password\":\"my_password\"}"  # payload

What's going on in this POST request? We're posting a new record to `https://reqbin.com/echo/post/json`, with the JSON payload `{\"login\":\"my_login\",\"password\":\"my_password\"}`. Your terminal should return `{"success":"true"}`, which means we've successfully posted our payload. Note that `-d` is a cURL flag meaning "data", and `-H` is a new header flag.

You can try this POST request as a [live example](https://reqbin.com/req/c-dwjszac0/curl-post-json-example) if you prefer.

Conclusion

Payload is the data you are actually transferring. All the language and architecture around it isn't important: the data we are actually sending and receiving is the payload.

Get your free
API
key now
4.8 from 1,863 votes
See why the best developers build on Abstract
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
No credit card required