{"_id":"5ba178b00a916500030c69bd","__v":0,"project":"59f79e3c584eb200345ceafc","user":"54e4044e8ef7552300409dcb","parentDoc":null,"version":{"_id":"5ba178b00a916500030c6a21","project":"59f79e3c584eb200345ceafc","__v":25,"forked_from":"59f79e3c584eb200345ceaff","createdAt":"2015-09-17T03:47:20.956Z","releaseDate":"2015-09-17T03:47:20.956Z","categories":["5ba178b00a916500030c69a2","5ba178b00a916500030c69a3","5ba178b00a916500030c69a4","5ba178b00a916500030c69a5","5ba178b00a916500030c69a6","5ba178b00a916500030c69a7","5ba178b00a916500030c69a8","5ba178b00a916500030c69a9","5ba178b00a916500030c69aa","5ba178b00a916500030c69ab","5ba178b00a916500030c69ac","5afb6888212c690003ae3d3b","5ba178b00a916500030c69ad","5ba178b00a916500030c69ae","5ba2dcbc99f53f0003b97e2c","5babd73fa0ab3e0003ead030","5bb4038be7222e000334dd97","5bb55954478c1300031a44c2","5bb665a1607307000327c81e","5bb6f90229a7fb0003a0650d","5bb7f9bc29a7fb0003a07ac1","5bba58bd7ba7710003bd901d","5bba6dac7ba7710003bd908d","5bba6e257ba7710003bd9090","5bbac87810189c0003e619ea","5bbb9d02b5862c00036266b2","5bbbadb6219c3e000376c2de","5bc417751d1b0000182bf7f6","5bc59e3b2a5b4f0044db5b97","5bc7bbce2262cc0041f6eff2","5bce6a3580a7250031199f34","5bcfac2c4082510019f2d91b","5bcfac3757bed90030e45d68","5bcfac45d305bc0049941539","5bd2a43548bb6f00289c8fad","5bd3a42a026ebe001f66259e","5bd9d5afffe003005b02f97b","5becb7ee85c6b300557662b6","5c5b12896f30e0004b3c8066"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"3.1.0","version":"3.1"},"category":{"_id":"5ba178b00a916500030c69a8","project":"59f79e3c584eb200345ceafc","version":"5ba178b00a916500030c6a21","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2017-05-12T16:39:43.277Z","from_sync":false,"order":1,"slug":"guides","title":"Resources"},"githubsync":"","updates":["56071fc33a93940d002b3f1e"],"next":{"pages":[],"description":""},"createdAt":"2015-09-17T04:06:19.096Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"## API Endpoint\nhttps://<i></i>api.synapsefi.com/v3.1\n\n##Headers\nClient and user authentication information is expected to be included as header values in your requests. \n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"KEY\",\n    \"h-1\": \"VALUE\",\n    \"h-2\": \"Comments\",\n    \"h-3\": \"Notes\",\n    \"0-0\": \"X-SP-GATEWAY\",\n    \"0-1\": \"`YOUR_CLIENT_ID`|`YOUR_CLIENT_SECRET`\",\n    \"0-2\": \"Your `client_id` and `client_secret` separated by a vertical bar. (required)\",\n    \"0-3\": \"You can send bulk instructions here\",\n    \"1-0\": \"X-SP-USER\",\n    \"1-1\": \"`USER_OAUTH_KEY`|`USER_FINGERPRINT`\",\n    \"1-2\": \"User’s `oauth_key` and device `fingerprint` separated by a vertical bar. (required)\",\n    \"1-3\": \"Paginated. Search by name and email available\",\n    \"2-1\": \"`USER_IP_ADDR`\",\n    \"2-0\": \"X-SP-USER-IP\",\n    \"2-2\": \"IP Address of the user. (required)\",\n    \"2-3\": \"Allows you to register a new user to SynapsePay\",\n    \"3-0\": \"X-SP-IDEMPOTENCY-KEY\",\n    \"3-1\": \"`IDEMPOTENCY_KEY`\",\n    \"3-2\": \"`idemopotency_key` for safely retrying requests. (optional)\"\n  },\n  \"cols\": 3,\n  \"rows\": 4\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"POST calls support idempotency for safely retrying requests without accidentally performing the same operation twice. For example, if a request to create a transaction fails due to a network connection error, you can retry the request with the same idempotency key to guarantee that only a single charge is created.\\n\\nTo perform an idempotent request, attach a unique key to any POST request made to the API via the `X-SP-IDEMPOTENCY-KEY` header.\\n\\nIdempotency keys expire after 24 hours.\",\n  \"title\": \"Idemopotent Requests\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"\"\n}\n[/block]\n##Client Libraries\n\nInstead of using the API directly, you can also use our client libraries. \n\n- [Python](https://github.com/SynapseFI/SynapsePy) \n- [Ruby](https://github.com/SynapseFI/SynapseRuby) \n- [PHP](https://github.com/SynapseFI/SynapsePHP) \n- [Node.js](https://github.com/SynapseFI/SynapseNode) \n- [Go](https://github.com/SynapseFI/SynapseGo)\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"For platforms using older versions of the client libraries we recommend updating to the new libraries above. The older libraries are no longer maintained and will soon be deprecated. \\n\\nNote: The previous libraries do not have the functionality to change personal to business. For any requests where you would like to change an account personal to business we recommend upgrading to the new library.\",\n  \"title\": \"Deprecated Client Libraries\"\n}\n[/block]\n\n[block:api-header]\n{}\n[/block]\n##Library Initialization\n\nThe following is how you initialize the environment for the libraries.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"import os\\nfrom synapse_pay_rest import Client\\n\\nargs = {\\n    'client_id': os.environ['CLIENT_ID'], # your client id\\n    'client_secret': os.environ['CLIENT_SECRET'], # your client secret\\n    'fingerprint': USER_FINGERPRINT,\\n    'ip_address': USER_IP_ADDRESS, # user's IP\\n    'development_mode': True, # (optional) default False\\n    'logging': False # (optional) logs to stdout if True\\n}\\n\\nclient = Client(**args)\",\n      \"language\": \"python\"\n    },\n    {\n      \"code\": \"const Synapse = require('synapsenode');\\nconst Client = Synapse.Client;\\n\\nconst args = {\\n  client_id: process.env.CLIENT_ID,\\n  client_secret: process.env.CLIENT_SECRET,\\n  fingerprint: process.env.FINGERPRINT,\\n  ip_address: '<ip_address>',\\n  // isProduction determines if production (true) or sandbox (false) endpoint is used\\n  isProduction: false\\n};\\n\\nconst client = new Client(args);\",\n      \"language\": \"javascript\",\n      \"name\": \"Node.js\"\n    },\n    {\n      \"code\": \"require 'synapse_pay_rest'\\n\\nargs = {\\n  # synapse client_id\\n  client_id:        ENV.fetch('CLIENT_ID'),\\n  # synapse client_secret\\n  client_secret:    ENV.fetch('CLIENT_SECRET'),\\n  # a hashed value, either unique to user or static for app\\n  fingerprint:      FINGERPRINT,\\n  # the user's IP\\n  ip_address:       USER_IP_ADDRESS,\\n  # (optional) requests go to sandbox endpoints if true\\n  development_mode: true,\\n  # (optional) if true logs requests to stdout\\n  logging:          true,\\n  # (optional) file path to write logs to\\n  log_to:           nil\\n}\\n\\nclient = SynapsePayRest::Client.new(args)\",\n      \"language\": \"ruby\"\n    },\n    {\n      \"code\": \"require(dirname(__FILE__) . '/../../init.php');\\n\\nuse SynapsePayRest\\\\Client;\\n\\n$options = array(\\n\\t'oauth_key'=> USER_OAUTH_KEY, # Optional,\\n\\t'fingerprint'=> USER_FINGERPRINT,\\n\\t'client_id'=> CLIENT_ID,\\n\\t'client_secret'=> CLIENT_SECRET,\\n\\t'development_mode'=> true, # true will ping sandbox.synapsepay.com\\n\\t'ip_address'=> USER_IP_ADDRESS\\n);\\n\\n$user_id = USER_ID # optionals\\n\\n$client = new Client($options, $user_id); // $user_id optional\",\n      \"language\": \"php\"\n    },\n    {\n      \"code\": \"import github.com/synapsefi/synapsego\\n\\n// credentials used to set headers for each method request\\nvar client = synapse.New(\\n\\\"CLIENT_ID\\\",\\n\\\"CLIENT_SECRET\\\",\\n\\\"IP_ADDRESS\\\",\\n\\\"FINGERPRINT\\\",\\n)\",\n      \"language\": \"go\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"Please note that you do not need to add `oauth_key` in the options dictionary after the user is created and oauth is performed. The libraries automatically do that for you.\",\n  \"title\": \"Automatic OAuth updates\"\n}\n[/block]","excerpt":"Following are the values you need to set in the header of your API call","slug":"api-initialization","type":"basic","title":"API Initialization"}

API Initialization

Following are the values you need to set in the header of your API call

## API Endpoint https://<i></i>api.synapsefi.com/v3.1 ##Headers Client and user authentication information is expected to be included as header values in your requests. [block:parameters] { "data": { "h-0": "KEY", "h-1": "VALUE", "h-2": "Comments", "h-3": "Notes", "0-0": "X-SP-GATEWAY", "0-1": "`YOUR_CLIENT_ID`|`YOUR_CLIENT_SECRET`", "0-2": "Your `client_id` and `client_secret` separated by a vertical bar. (required)", "0-3": "You can send bulk instructions here", "1-0": "X-SP-USER", "1-1": "`USER_OAUTH_KEY`|`USER_FINGERPRINT`", "1-2": "User’s `oauth_key` and device `fingerprint` separated by a vertical bar. (required)", "1-3": "Paginated. Search by name and email available", "2-1": "`USER_IP_ADDR`", "2-0": "X-SP-USER-IP", "2-2": "IP Address of the user. (required)", "2-3": "Allows you to register a new user to SynapsePay", "3-0": "X-SP-IDEMPOTENCY-KEY", "3-1": "`IDEMPOTENCY_KEY`", "3-2": "`idemopotency_key` for safely retrying requests. (optional)" }, "cols": 3, "rows": 4 } [/block] [block:callout] { "type": "info", "body": "POST calls support idempotency for safely retrying requests without accidentally performing the same operation twice. For example, if a request to create a transaction fails due to a network connection error, you can retry the request with the same idempotency key to guarantee that only a single charge is created.\n\nTo perform an idempotent request, attach a unique key to any POST request made to the API via the `X-SP-IDEMPOTENCY-KEY` header.\n\nIdempotency keys expire after 24 hours.", "title": "Idemopotent Requests" } [/block] [block:api-header] { "type": "basic", "title": "" } [/block] ##Client Libraries Instead of using the API directly, you can also use our client libraries. - [Python](https://github.com/SynapseFI/SynapsePy) - [Ruby](https://github.com/SynapseFI/SynapseRuby) - [PHP](https://github.com/SynapseFI/SynapsePHP) - [Node.js](https://github.com/SynapseFI/SynapseNode) - [Go](https://github.com/SynapseFI/SynapseGo) [block:callout] { "type": "info", "body": "For platforms using older versions of the client libraries we recommend updating to the new libraries above. The older libraries are no longer maintained and will soon be deprecated. \n\nNote: The previous libraries do not have the functionality to change personal to business. For any requests where you would like to change an account personal to business we recommend upgrading to the new library.", "title": "Deprecated Client Libraries" } [/block] [block:api-header] {} [/block] ##Library Initialization The following is how you initialize the environment for the libraries. [block:code] { "codes": [ { "code": "import os\nfrom synapse_pay_rest import Client\n\nargs = {\n 'client_id': os.environ['CLIENT_ID'], # your client id\n 'client_secret': os.environ['CLIENT_SECRET'], # your client secret\n 'fingerprint': USER_FINGERPRINT,\n 'ip_address': USER_IP_ADDRESS, # user's IP\n 'development_mode': True, # (optional) default False\n 'logging': False # (optional) logs to stdout if True\n}\n\nclient = Client(**args)", "language": "python" }, { "code": "const Synapse = require('synapsenode');\nconst Client = Synapse.Client;\n\nconst args = {\n client_id: process.env.CLIENT_ID,\n client_secret: process.env.CLIENT_SECRET,\n fingerprint: process.env.FINGERPRINT,\n ip_address: '<ip_address>',\n // isProduction determines if production (true) or sandbox (false) endpoint is used\n isProduction: false\n};\n\nconst client = new Client(args);", "language": "javascript", "name": "Node.js" }, { "code": "require 'synapse_pay_rest'\n\nargs = {\n # synapse client_id\n client_id: ENV.fetch('CLIENT_ID'),\n # synapse client_secret\n client_secret: ENV.fetch('CLIENT_SECRET'),\n # a hashed value, either unique to user or static for app\n fingerprint: FINGERPRINT,\n # the user's IP\n ip_address: USER_IP_ADDRESS,\n # (optional) requests go to sandbox endpoints if true\n development_mode: true,\n # (optional) if true logs requests to stdout\n logging: true,\n # (optional) file path to write logs to\n log_to: nil\n}\n\nclient = SynapsePayRest::Client.new(args)", "language": "ruby" }, { "code": "require(dirname(__FILE__) . '/../../init.php');\n\nuse SynapsePayRest\\Client;\n\n$options = array(\n\t'oauth_key'=> USER_OAUTH_KEY, # Optional,\n\t'fingerprint'=> USER_FINGERPRINT,\n\t'client_id'=> CLIENT_ID,\n\t'client_secret'=> CLIENT_SECRET,\n\t'development_mode'=> true, # true will ping sandbox.synapsepay.com\n\t'ip_address'=> USER_IP_ADDRESS\n);\n\n$user_id = USER_ID # optionals\n\n$client = new Client($options, $user_id); // $user_id optional", "language": "php" }, { "code": "import github.com/synapsefi/synapsego\n\n// credentials used to set headers for each method request\nvar client = synapse.New(\n\"CLIENT_ID\",\n\"CLIENT_SECRET\",\n\"IP_ADDRESS\",\n\"FINGERPRINT\",\n)", "language": "go" } ] } [/block] [block:callout] { "type": "info", "body": "Please note that you do not need to add `oauth_key` in the options dictionary after the user is created and oauth is performed. The libraries automatically do that for you.", "title": "Automatic OAuth updates" } [/block]