Moesif Setup

Last updated: 4 minutes read.

This is a step by step guide to setting up Moesif API Analytics and Monetization platform to understand customer API usage and setup usage-based billing.

We also have a blog post which highlights how Tyk and Moesif work together.

The assumptions are that you have Docker installed and Tyk Self-Managed already running. See the Tyk Pump Configuration for more details.


With the Moesif Tyk plugin, your API logs are sent to Moesif asynchronously to provide analytics on customer API usage along with your API payloads like JSON and XML. This plugin also enables you to monetize your API with billing meters and provide a self-service onboarding experience. Moesif also collects information such as the authenticated user (AliasId or OAuthId) to identify customers using your API. An overview on how Moesif and Tyk works together is available here.

1. Get a Moesif Application Id

Go to and sign up for a free account. Application Ids are write-only API keys specific to an application in Moesif such as “Development” or “Production”. You can always create more applications in Moesif.

2. Enable Moesif backend in Tyk Pump

Add Moesif as an analytics backend along with your Moesif Application Id you obtained in the last step to your Tyk Pump Configuration

JSON / Conf File
    "pumps": {
        "moesif": {
            "name": "moesif",
            "meta": {
            "application_id": "Your Moesif Application Id"
Env Variables:

3. Ensure analytics is enabled

If you want to log HTTP headers and body, ensure the detailed analytics recording flag is set to true in your Tyk Gateway Conf

JSON / Conf File
    "enable_analytics" : true,
    "analytics_config": {
      "enable_detailed_recording": true
Env Variables:


This will enable detailed recording globally, across all APIs. This means that the behavior of individual APIs that have this configuration parameter set will be overridden. The Gateway must be restarted after updating this configuration parameter.

4. Restart Tyk Pump to pickup the Moesif config

Once your config changes are done, you need to restart your Tyk Pump and Tyk Gateway instances (if you’ve modified Tyk gateway config). If you are running Tyk Pump in Docker:

$ docker restart tyk-pump


You can now make a few API calls and verify they show up in Moesif.

$ curl localhost:8080


The Moesif Tyk integration automatically maps a Tyk Token Alias to a user id in Moesif. With a Moesif SDK, you can store additional customer demographics to break down API usage by customer email, company industry, and more.

Configuration options

The Tyk Pump for Moesif has a few configuration options that can be set in your pump.env:

Parameter Required Description Environment Variable
application_id required Moesif Application Id. Multiple Tyk api_id’s will be logged under the same app id. TYK_PMP_PUMPS_MOESIF_META_APPLICATIONID
request_header_masks optional Mask a specific request header field. Type: String Array [] string TYK_PMP_PUMPS_MOESIF_META_REQUESTHEADERMASKS
request_body_masks optional Mask a specific - request body field. Type: String Array [] string TYK_PMP_PUMPS_MOESIF_META_REQUESTBODYMASKS
response_header_masks optional Mask a specific response header field. Type: String Array [] string TYK_PMP_PUMPS_MOESIF_META_RESPONSEHEADERMASKS
response_body_masks optional Mask a specific response body field. Type: String Array [] string TYK_PMP_PUMPS_MOESIF_META_RESPONSEBODYMASKS
disable_capture_request_body optional Disable logging of request body. Type: Boolean. Default value is false. TYK_PMP_PUMPS_MOESIF_META_DISABLECAPTUREREQUESTBODY
disable_capture_response_body optional Disable logging of response body. Type: Boolean. Default value is false. TYK_PMP_PUMPS_MOESIF_META_DISABLECAPTURERESPONSEBODY
user_id_header optional Field name to identify User from a request or response header. Type: String. Default maps to the token alias TYK_PMP_PUMPS_MOESIF_META_USERIDHEADER
company_id_header optional Field name to identify Company (Account) from a request or response header. Type: String TYK_PMP_PUMPS_MOESIF_META_COMPANYIDHEADER

Identifying users

By default, the plugin will collect the authenticated user (AliasId or OAuthId) to identify the customer. This can be overridden by setting the user_id_header to a header that contains your API user/consumer id such as X-Consumer-Id. You can also set the company_id_header which contains the company to link the user to. See Moesif docs on identifying customers