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:
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.
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.