Skip to main content

Hi There,

 

I am getting a 500 error for one of our customer when I try to list all templates within their instance.

Here’s the URL to which the request is made:

https://a.klaviyo.com/api/templates/

revision: '2024-07-15'

filter: greater-than(updated,1970-01-02)

Here;s the error message that we are receiving

"errors":r{"id":"aec7226b-df4a-48f7-aef7-b88d0023cc06","status":500,"code":"error","title":"A server error occurred.","detail":"","source":{"pointer":"/data"},"links":{},"meta":{}}]}

Here’s another instance of this same error but from a totally different customer:

{"errors":"{"id":"23a1abb8-92a2-45d6-98ea-11f941172bef","status":500,"code":"error","title":"A server error occurred.","detail":"","source":{"pointer":"/data"},"links":{},"meta":{}}]}

Hi Parth,

If you drop the filter for updated after 1970-01-02, do you still get a 500 error?


           1. Check API Endpoint and Parameters

  • Verify that the API endpoint (https://a.klaviyo.com/api/templates/) and the parameters (revision and filter) are correct and match Klaviyo's API documentation.
  • Ensure that the revision date (2024-07-15) and filter parameter (greater-than(updated,1970-01-02)) are correctly formatted and supported by the API.
  • 2. Confirm API Authentication

  • Ensure you are authenticating properly with Klaviyo's API key in the headers or as required:
     

    http

    Copy code

    Authorization: Bearer YOUR_API_KEY

  • 3. Validate the Filter Parameter

  • The filter greater-than(updated,1970-01-02) could be causing the issue. Double-check Klaviyo's API documentation to confirm the correct syntax for filtering.
  • If the updated field doesn't exist or is not filterable, it may result in a 500 error. Test with a simpler query (e.g., no filter) to isolate the issue.
  • 4. Use Postman or CURL for Testing

  • Test the API call with tools like Postman or CURL to rule out issues with your code. For example:
     

    bash

    Copy code

    curl -X GET "https://a.klaviyo.com/api/templates/" \ -H "Authorization: Bearer YOUR_API_KEY"

  • 5. Inspect the Response and Logs

  • Look for more detailed error information in the response. If detail is empty, the problem is likely on Klaviyo's end.
  • If you have access to logs from your application, check if there are any clues (e.g., malformed requests or timeouts).
  • 6. Simplify and Test the Request

  • Remove the revision and filter parameters temporarily to see if the basic request works:
     

    bash

    Copy code

    curl -X GET "https://a.klaviyo.com/api/templates/" \ -H "Authorization: Bearer YOUR_API_KEY"

  • If this succeeds, add parameters one by one to identify the problematic one.
  • 7. Check Klaviyo's API Status

  • Visit Klaviyo's status page to see if there are ongoing issues with their API services.

Hi ​@ParthAtRewind!

Thank you for posting in the Community!

First and foremost:

1. Verify the API endpoint and parameters:

First, double-check that the API endpoint and parameters match Klaviyo’s API documentation. For example:

  • Endpoint: Ensure you are using https://a.klaviyo.com/api/templates/.
  • Revision: Confirm that revision: '2024-07-15' is a valid and supported version of the API.
  • Filter syntax: The filter you’re using, greater-than(updated,1970-01-02), may not be correctly formatted. Klaviyo typically expects filter parameters to use the following syntax:

    filter=updated>1970-01-02

    Replace greater-than with > and ensure there are no unnecessary spaces or formatting issues.

2. Ensure proper authentication:

Klaviyo’s API requires authentication using a API Token. Make sure your request includes the correct API key in the headers:

Authorization: Klaviyo-api - YOUR_API_KEY

Additionally, ensure the API key has the necessary permissions to access templates.

3. Simplify and test the request:

To isolate the issue, start with the simplest possible request:

curl -X GET "https://a.klaviyo.com/api/templates/" \ -H "Authorization: Klaviyo-API YOUR_API_KEY"

If this request succeeds, gradually add back parameters like revision and filter to pinpoint the cause of the error.

4. Validate the filter parameter:

The filter you’re using may not be supported or properly configured. Double-check the following:

  • Ensure that the updated field exists and is filterable.
  • Test without the filter to see if the request works:

    curl -X GET "https://a.klaviyo.com/api/templates/" \ -H "Authorization: Klaviyo-API YOUR_API_KEY"

If this works, reintroduce the filter parameter to confirm it’s the source of the issue.

5. Inspect the error response:

The error response indicates a server-side issue:

"errors":c{"id":"...","status":500,"code":"error","title":"A server error occurred.","detail":"","source":{"pointer":"/data"}}]

Since the detail field is empty, it suggests that Klaviyo’s servers are encountering a problem processing your request. However, it’s worth ensuring that your request is correctly formed to rule out any issues on your end, such as malformed headers or unsupported parameters.

6. Temporarily remove the revision parameter:

Try omitting the revision parameter to see if it resolves the issue. Some API versions may not fully support all features, even if documented.

Hope that helps! :-) 

Christian Nørbjerg Enger
Partner & CPO
Web: Segmento.dk
LinkedIn: @christianfromsegmento
Voldbjergvej 22b, 8240 Risskov


The thing is not every customer of ours is facing this, so I doubt that the api formatting is the reason for failure.

However with that said I will switch over to latest revision when time permits and will follow up with findings.

 

Also is it not possible to trace the reason for failure via error id that’s present in the response?

 

Best,

Parth


Reply