{"__v":9,"_id":"56f435887ea0091700f63b02","category":{"__v":1,"_id":"56d9d4287222d50b0070160b","pages":["56d9d483aa96cc150020eb35"],"project":"568af724176a6c0d00a29ec4","version":"568af725176a6c0d00a29ec7","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-03-04T18:30:00.578Z","from_sync":false,"order":2,"slug":"monetized-urls","title":"Monetized URLs"},"parentDoc":null,"project":"568af724176a6c0d00a29ec4","user":"568af6d197d8960d0012ab7d","version":{"__v":9,"_id":"568af725176a6c0d00a29ec7","project":"568af724176a6c0d00a29ec4","createdAt":"2016-01-04T22:50:13.289Z","releaseDate":"2016-01-04T22:50:13.289Z","categories":["568af725176a6c0d00a29ec8","56d9d397337fd11300d6a3e3","56d9d4287222d50b0070160b","56f424307ea0091700f63ac5","56f45babcb0dce29005a8e85","5739e5836c5ba134007a197d","57717aee3dd24019004c9122","5771b5d8c755ca0e00617d7d","579639964913990e001a5911"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"createdAt":"2016-03-24T18:44:24.830Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"examples":{"codes":[]},"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"Creating one-off monetized URLs is easy using [VigLink Anywhere](http://www.viglink.com/products/anywhere). Paste any URL and get a portable VigLink URL which monetizes the original whenever possible.\n\nIt’s sometimes useful to create VigLink Anywhere URLs programmatically. The URL format and behavior are documented below.\n\n##**Request**\n\nURL: http://redirect.viglink.com\nMethod: GET\n\n##**Parameters**\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Parameter\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"key\",\n    \"0-1\": \"string\",\n    \"0-2\": \"Your VigLink API key, found on your account page.  *Required\",\n    \"1-0\": \"u\",\n    \"1-1\": \"string\",\n    \"1-2\": \"The URL to monetize.  *Required\"\n  },\n  \"cols\": 3,\n  \"rows\": 2\n}\n[/block]\nNote: VigLink Anywhere wraps the [link monetization API](https://viglink-merchant-api.readme.io/docs/building-monetized-links). If any of those parameters are included, they’ll be passed through to the underlying API. One case where that’s especially useful is [advanced revenue tracking](https://viglink-merchant-api.readme.io/docs/overview)—just pass your cuid like normal.\n\n##**Response**\n\nThe server will respond with one of these HTTP status codes:\n\n302\nThe request was successful. The client should be redirected.\n\nIf the input URL (specified by the u parameter) could be monetized, the client is redirected to the monetized version of that URL. If there is no monetized version, the client is redirected to the original URL, unmodified.\n\n400\nRequired parameters are missing, or their values are not valid.\n403\nThe specified URL is unsafe.\n\nTo protect users from malicious web sites, URLs are checked against a list of “bad” sites before redirecting. If the URL is found to be unsafe, a warning page is displayed. For more information visit [stopbadware.org](http://stopbadware.org/).\n\n##**Example**\n\nYou’d like to share a monetized version of this URL: http://amazon.com/dp/0316769487\n\nAfter building the monetized link, it should look something like this:\nhttp://redirect.viglink.com?u=http%3A%2F%2Famazon.com%2Fdp%2F0316769487&key=88ac2a40e081e283ac504d1789d398ac\n\nWhen someone follows the VigLink URL, they’ll be redirected to the monetized version of your original URL:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$ curl -D - 'http://redirect.viglink.com?u=http%3A%2F%2Famazon.com%2Fdp%2F0316769487&key=88ac2a40e081e283ac504d1789d398ac'\\n        \\nHTTP/1.1 302 Moved Temporarily\\nContent-Length: 0\\nLocation: http://amazon.com/dp/0316769487?tag=vig-20\",\n      \"language\": \"curl\"\n    }\n  ]\n}\n[/block]","excerpt":"VigLink Anywhere let's you create one-off monetized URLs programmatically.","slug":"building-monetized-urls","type":"basic","title":"Building Monetized URLs"}

Building Monetized URLs

VigLink Anywhere let's you create one-off monetized URLs programmatically.

Creating one-off monetized URLs is easy using [VigLink Anywhere](http://www.viglink.com/products/anywhere). Paste any URL and get a portable VigLink URL which monetizes the original whenever possible. It’s sometimes useful to create VigLink Anywhere URLs programmatically. The URL format and behavior are documented below. ##**Request** URL: http://redirect.viglink.com Method: GET ##**Parameters** [block:parameters] { "data": { "h-0": "Parameter", "h-1": "Type", "h-2": "Description", "0-0": "key", "0-1": "string", "0-2": "Your VigLink API key, found on your account page. *Required", "1-0": "u", "1-1": "string", "1-2": "The URL to monetize. *Required" }, "cols": 3, "rows": 2 } [/block] Note: VigLink Anywhere wraps the [link monetization API](https://viglink-merchant-api.readme.io/docs/building-monetized-links). If any of those parameters are included, they’ll be passed through to the underlying API. One case where that’s especially useful is [advanced revenue tracking](https://viglink-merchant-api.readme.io/docs/overview)—just pass your cuid like normal. ##**Response** The server will respond with one of these HTTP status codes: 302 The request was successful. The client should be redirected. If the input URL (specified by the u parameter) could be monetized, the client is redirected to the monetized version of that URL. If there is no monetized version, the client is redirected to the original URL, unmodified. 400 Required parameters are missing, or their values are not valid. 403 The specified URL is unsafe. To protect users from malicious web sites, URLs are checked against a list of “bad” sites before redirecting. If the URL is found to be unsafe, a warning page is displayed. For more information visit [stopbadware.org](http://stopbadware.org/). ##**Example** You’d like to share a monetized version of this URL: http://amazon.com/dp/0316769487 After building the monetized link, it should look something like this: http://redirect.viglink.com?u=http%3A%2F%2Famazon.com%2Fdp%2F0316769487&key=88ac2a40e081e283ac504d1789d398ac When someone follows the VigLink URL, they’ll be redirected to the monetized version of your original URL: [block:code] { "codes": [ { "code": "$ curl -D - 'http://redirect.viglink.com?u=http%3A%2F%2Famazon.com%2Fdp%2F0316769487&key=88ac2a40e081e283ac504d1789d398ac'\n \nHTTP/1.1 302 Moved Temporarily\nContent-Length: 0\nLocation: http://amazon.com/dp/0316769487?tag=vig-20", "language": "curl" } ] } [/block]