I’m new to Cloudflare. I need an activity log of email routing using an API. I’ve attached a screenshot of what I can see on the web-console at dash.cloudflare.com => Domain => Email.
This query returns no data:
curl -H "X-Auth-Email: " -H "X-Auth-Key: " -H “Content-Type: application/json”
-X GET “https://api.cloudflare.com/client/v4/zones//access/logs/access_requests?limit=25&direction=desc&since=2022-05-01T05:20:00Z&until=2022-05-12T05:20:00Z”
How can I get the activity log of email routing that you can see on the dashboard?
Thanks.
Officially, there is no API for email routing yet. However, you can do it with the GraphQL. The endpoint is https://api.cloudflare.com/client/v4/graphql
and a request with curl looks like
curl --location --request POST 'https://api.cloudflare.com/client/v4/graphql' \
--header 'X-AUTH-KEY: X-AUTH-KEY' \
--header 'X-AUTH-EMAIL: X-AUTH-EMAIL' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"{\n viewer {\n zones(filter: {zoneTag: $zoneTag}) \n {\n emailRoutingAdaptive(limit: 1000, filter: $filter, orderBy: [datetime_DESC, from_ASC, to_ASC, status_ASC]){ datetime id: sessionId from to status spf dkim dmarc errorDetail __typename } __typename } __typename }\r\n}","variables":{"zoneTag":"<Zone ID>","filter":{"datetime_geq":<Start Date>"","datetime_leq":"<End Date>"}}}'
Example Start Date: 2022-05-12T19:45:00.000Z
Example End Date: 2022-05-13T19:45:00.000Z
1 Like
system
closed
May 16, 2022, 8:14pm
#3
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.