Before you can send data to an API from your WordPress site to external services, you need to configure the API connection. This article walks you through configuring the API endpoint, HTTP method, authentication, and request details for sending data.
Overview
When setting up an API for sending data, you are configuring how your WordPress site will communicate with external services. This includes:
- Where to send the data (the API endpoint URL)
- How to send it (HTTP method like POST or PUT)
- Any credentials or authentication required
- How to format and structure the data being sent
- What to include in headers, parameters, or body
Unlike the “Displaying” workflow which fetches data from APIs, the “Sending” workflow pushes data to external services when events occur on your WordPress site.
Basic Configuration
API Name
Give your API a descriptive name that indicates both the destination and purpose. This name appears in your WordPress admin and helps you identify which API to use when setting up triggers.
Examples: “Send to Mailchimp”, “Slack Notifications”, “CRM Contact Sync”, “Zapier Integration”
Endpoint URL
Enter the complete URL where you want to send data. This is the receiving endpoint on the external service. The URL should include the protocol (http:// or https://).
Example: https://hooks.slack.com/services/YOUR/WEBHOOK/URL
Check your external service’s documentation to find the correct webhook or API endpoint URL. Many services provide a specific URL where you send data.
HTTP Method
Select the appropriate HTTP method for sending data. For most sending scenarios, you will use POST:
| Method | Use When | Description |
|---|---|---|
| POST | Creating new records or sending data (most common) | Used to submit data to the external service. Most webhooks and APIs expect POST. |
| PUT | Updating existing records on external system | Replaces an entire record. Less common for webhooks. |
| PATCH | Partially updating existing records | Modifies specific fields without replacing entire record. |
| GET | Querying data (not for sending) | Generally not used for sending operations. |
| DELETE | Deleting records from external system | Rarely used for webhook integrations. |
Check your external API documentation. If it says “send a webhook” or “post data”, use POST. Most services will specify which method to use.
Request Details
Query Parameters
Query parameters are optional values appended to the URL to provide additional context or filtering. They appear after the ? symbol in a URL.
Example URL with parameters: https://api.example.com/webhook?source=wordpress&priority=high
Common reasons to add parameters when sending:
- Specify the type of data being sent
- Set priority or urgency levels
- Include source identification
- Add API keys or tokens (though headers are more secure)
Check the receiving service’s documentation to see if it requires or supports query parameters.
Headers
HTTP headers provide metadata about your request and tell the external service how to interpret the data you are sending.
Essential headers for sending data:
| Header | Purpose | Common Value |
|---|---|---|
Content-Type |
Format of data in the request body | application/json (for JSON) or application/x-www-form-urlencoded (for form data) |
Authorization |
Authentication credentials | Bearer YOUR_TOKEN or other auth method |
User-Agent |
Identifies your application | WordPress/API-Press |
X-Custom-Header |
API-specific requirements | Varies by service |
Accept |
Expected response format | application/json |
API Press will typically add the Content-Type header automatically based on your body format. Check your external service’s documentation for required headers.
Request Body
The request body contains the actual data you are sending to the external service. For sending operations, you almost always use POST, PUT, or PATCH methods with a body.
Body Type: Choose how to format the data:
- form-data – Traditional form submission format (key-value pairs). Good for simple data.
- raw JSON – JSON format. Most APIs prefer this for complex data structures.
Body Structure Example
Here is what a typical body might look like when sending data:
The structure depends on what the receiving service expects. Check their API documentation for required fields and format.
Authentication
Many external services require authentication to verify that your requests are legitimate and come from an authorized source. API Press supports multiple authentication methods:
No Authentication
Some webhooks or services are public and do not require authentication. Leave the authentication settings empty.
When to use: Only if the service explicitly states it does not require authentication.
Bearer Token (Most Common)
This is the most common authentication method for modern APIs and webhooks. You receive a token from the service and include it with each request.
How to use:
- Select Bearer Token as the authentication type
- Paste your token into the Bearer Token field
- API Press automatically adds the header:
Authorization: Bearer [your-token]
Where to find your token:
- Slack: Webhook URL contains the token
- Zapier: Generated in your Zapier account
- Mailchimp: API keys in account settings
- Custom APIs: Check the service’s documentation
Basic Authentication (Username/Password)
Some services use traditional username and password authentication. This is less common for webhooks but still used by some APIs.
How to use:
- Select Basic Auth as the authentication type
- Enter your username and password
- API Press automatically encodes and sends these credentials
Custom Header Authentication
Some APIs use custom authentication schemes with specific header names. For these cases:
- Add the authentication header in the Headers section
- Use the exact header name the service specifies (e.g.,
X-API-Key) - Set the value to your authentication credential
Example:
- Header name:
X-API-Key - Header value:
your-secret-api-key-here
Advanced Settings
Response Format
Select how the external API returns responses:
- JSON – Most common. API Press expects JSON-formatted responses.
- PHP Array – Less common. Used if the service returns PHP serialized data.
Nearly all modern APIs and webhooks use JSON. The external service documentation will specify what format it uses.
Timeout
Set the maximum number of seconds to wait for the external API to respond. If the service does not respond within this time, the request is cancelled.
Recommended value: 10-30 seconds. Set to 0 to use WordPress default timeout (usually 5 seconds).
SSL Certificate Bypass (Advanced)
By default, API Press verifies SSL certificates when connecting to HTTPS URLs. This ensures secure communication. In rare cases, you may need to disable this verification (for example, if testing with a self-signed certificate in development).
Testing Your Configuration
Before relying on your API in production, test it to ensure data is being sent correctly:
Option 1: Use a Test Webhook Service
Services like httpbin.org or webhook.site are free tools that receive and display webhook data. Perfect for testing:
- Go to https://webhook.site (no signup required)
- Copy the unique URL shown on the page
- Use that URL as your API endpoint in API Press
- Trigger the event (publish a post, register a user, etc.)
- Refresh webhook.site to see the data that was sent
Option 2: Test with Your External Service
If you have a test account with your external service:
- Use the test/staging endpoint provided by the service
- Configure it in API Press
- Trigger the event and check if data appears in the test account
- Verify data structure matches what the service expects
Option 3: Enable Request Logging
Use API Press logging to see details of what was sent:
- Enable logging for your API
- Trigger the event
- Go to API Press > Logs to see request details
- Check response status, headers, and body
Common Integration Examples
Slack Webhook
Endpoint: Your Slack Incoming Webhook URL from app.slack.com
Method: POST
Body Type: Raw JSON
Authentication: None (URL contains the token)
Body:
Zapier Webhook
Endpoint: Your Zapier webhook URL (provided when setting up a Zap)
Method: POST
Body Type: Raw JSON
Authentication: None (URL contains the token)
Body:
Custom REST API
Endpoint: Your service’s API endpoint
Method: POST (or specified by service)
Body Type: Raw JSON
Authentication: Bearer Token (check service for specific token format)
Headers to add:
- Content-Type: application/json
- X-Custom-Header: (any service-specific headers)
Using Variables in Your Requests
API Press supports dynamic variables that get replaced with real event data when sending. For example:
[[user.email]]becomes the actual user’s email[[post.title]]becomes the actual post title[[date:Y-m-d]]becomes the current date
See the “Understanding Triggers” article for a complete list of available variables for each trigger type.
Troubleshooting Setup Issues
Connection Failed / Cannot Reach Endpoint
Solution: Check that:
- The endpoint URL is correct and spelled exactly
- The endpoint starts with https:// or http://
- Your server can access the internet and reach the external service
- The external service is online and responding
- No firewall or proxy is blocking the connection
Authentication Failed / 401 Error
Solution: Verify that:
- Your authentication credentials (token, username/password) are correct
- Credentials are not expired or revoked
- Authentication header format is correct (Bearer token should be “Bearer YOUR_TOKEN”)
- Basic auth username/password are entered in correct order
- Regenerate credentials if needed and update in API Press
Request Rejected / 400 Error
Solution: Check that:
- Request body format matches what the service expects (JSON vs form-data)
- Required fields are included in the body
- Field names match exactly (case-sensitive)
- Data types are correct (numbers vs strings)
- Headers are correct (especially Content-Type)
Service Returned Error / 5xx Status
Solution:
- The external service may be experiencing issues. Check their status page.
- Review error details in API Press logs
- Contact the external service’s support
- Check if there are limits on request frequency
Data Not Formatted Correctly
Solution:
- Compare sent data with service requirements in their documentation
- Use a test webhook service (webhook.site) to see exactly what is being sent
- Check that variables are being replaced with actual values
- Verify JSON is valid (use a JSON validator)
