How to return dummy response from tyk API without hitting back end. (TYK v2.5.1 opensource)

I am trying to create an API in tyk which can return response without calling target url.
Is there any way to do that in tyk. If yes pls share the parameter to be added in api definition json for same.


Hi @Mohit_Kumar ,
Welcome to our community and thank you for your inquiry.
It seems that v2.5.1 is an old version. Is there a reason why you are using an old version of Gateway? I suggest to use the LTS version 4.0.12.

Nevertheless to answer your question, you can use Mock Response. In your API definition, you just need to whitelist your endpoint and put the mock response inside the data as seen here:

    "version_data": {
      "not_versioned": true,
      "default_version": "",
      "versions": {
        "Default": {
          "name": "Default",
          "expires": "",
          "paths": {
            "ignored": [],
            "white_list": [],
            "black_list": []
          "use_extended_paths": true,
          "global_headers": {},
          "global_headers_remove": [],
          "global_response_headers": {},
          "global_response_headers_remove": [],
          "ignore_endpoint_case": false,
          "global_size_limit": 0,
          "override_target": "",
          "extended_paths": {
            "white_list": [
                "path": "/",
                "ignore_case": false,
                "method_actions": {
                  "GET": {
                    "action": "reply",
                    "code": 200,
                    "data": "THIS_IS_A_MOCK_RESPONSE_SAMPLE",
                    "headers": {}

Hey! Thanks for quick response. surely will be upgrading to the latest version soon as suggested.

Tried the given example, this worked.
Thanks! for the help.