> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.vtuagent.com/api-reference/vtu-agent-consumable-api/cable-tv/purchase-cable-tv-subscription/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.vtuagent.com/_mcp/server. # Purchase Cable TV Subscription POST https://api.vtuagent.com/v1/cabletv/purchase Content-Type: application/json Renews or changes a cable TV subscription for a smartcard / IUC number. **Before calling:** verify the smartcard with `POST /v1/cabletv/verify`, and fetch a valid `package_code` + `price` from `POST /v1/cabletv/variations`. Send that price as `amount`. Your wallet is debited **immediately**, then the provider is called synchronously. This endpoint does **not** long-poll or send a webhook — the HTTP response is final unless it is `202 pending`, in which case resolve it with `POST /v1/transaction/status`. | HTTP | `status` | `status_code` | Meaning | |---|---|---|---| | 200 | `successful` | 200 | Subscription activated | | 202 | `pending` | 202 | Provider still processing — poll `/v1/transaction/status` | | 400 | `error` | — | Bad payload, validation failure, insufficient balance, or duplicate `request_ref` | | 401 | — | — | Missing, invalid or revoked API key | | 424 | `failed` | 424 | Provider rejected the purchase — wallet refunded | | 500 | `error` | — | Provider unreachable | Reference: https://docs.vtuagent.com/api-reference/vtu-agent-consumable-api/cable-tv/purchase-cable-tv-subscription ## Authentication - `Authorization` header (bearer token, required) — API key issued from the VTUAgent dashboard, sent as `Authorization: Bearer {your_api_key}`. ## Request ### Body (application/json) This endpoint expects a CablePurchaseRequest. - `product_type` (enum, required) - Allowed values: `dstv`, `gotv`, `startimes` - `smartcard_number` (string, required) - `package_code` (string, required) — From POST /v1/cabletv/variations. - `amount` (CablePurchaseRequestAmount, required) — Package price from POST /v1/cabletv/variations. - `phone` (string, required) - `subscription_type` (enum, required) - Allowed values: `renew`, `change` - `request_ref` (string, required) — Your unique reference for this transaction, max 50 characters. A UUID is recommended. Re-using one is rejected with 400. ## Response ### 200 Subscription activated - `status` (enum, required) - Allowed values: `successful`, `pending`, `failed` - `status_code` (enum, required) — Always equals the HTTP status. - Allowed values: `200`, `202`, `424` - `message` (string, required) - `reference` (string, optional) — Echo of your request_ref. - `data` (map from string to any, optional) — Product-specific details; see the endpoint examples. ### 202 Provider still processing — poll `/v1/transaction/status` - `status` (enum, required) - Allowed values: `successful`, `pending`, `failed` - `status_code` (enum, required) — Always equals the HTTP status. - Allowed values: `200`, `202`, `424` - `message` (string, required) - `reference` (string, optional) — Echo of your request_ref. - `data` (map from string to any, optional) — Product-specific details; see the endpoint examples. ## Errors ### 400 Bad Request Error Invalid payload, validation error, insufficient balance, or duplicate request_ref - `status` (enum, required) - Allowed values: `error` - `message` (string, required) - `error` (string, optional) — Validator detail, present only on validation failures. ### 401 Unauthorized Error Missing, invalid or revoked API key. Note: this envelope has no `status` field. - `message` (string, required) - `error` (string, required) ### 424 Failed Dependency Error Provider rejected the purchase — wallet refunded - `status` (enum, required) - Allowed values: `successful`, `pending`, `failed` - `status_code` (enum, required) — Always equals the HTTP status. - Allowed values: `200`, `202`, `424` - `message` (string, required) - `reference` (string, optional) — Echo of your request_ref. - `data` (map from string to any, optional) — Product-specific details; see the endpoint examples. ### 500 Internal Server Error Internal error - `status` (enum, required) - Allowed values: `error` - `message` (string, required) - `error` (string, optional) — Validator detail, present only on validation failures. ## Types ### CablePurchaseRequestAmount Package price from POST /v1/cabletv/variations. ## Examples **Request** ```json { "product_type": "dstv", "smartcard_number": "1212121212", "package_code": "dstv-compact", "amount": 19000, "phone": "08012345678", "subscription_type": "renew", "request_ref": "b7e2f4a1-3d5c-4e6f-8a9b-0c1d2e3f4a5b" } ``` **Response** ```json { "status": "successful", "status_code": 200, "message": "Cable TV purchase was successful", "reference": "b7e2f4a1-3d5c-4e6f-8a9b-0c1d2e3f4a5b", "data": { "amount": "19000", "package_code": "dstv-compact", "smartcard_number": "1212121212" } } ``` **SDK Code** ```python import requests url = "https://api.vtuagent.com/v1/cabletv/purchase" payload = { "product_type": "dstv", "smartcard_number": "1212121212", "package_code": "dstv-compact", "amount": 19000, "phone": "08012345678", "subscription_type": "renew", "request_ref": "b7e2f4a1-3d5c-4e6f-8a9b-0c1d2e3f4a5b" } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.vtuagent.com/v1/cabletv/purchase'; const options = { method: 'POST', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{"product_type":"dstv","smartcard_number":"1212121212","package_code":"dstv-compact","amount":19000,"phone":"08012345678","subscription_type":"renew","request_ref":"b7e2f4a1-3d5c-4e6f-8a9b-0c1d2e3f4a5b"}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.vtuagent.com/v1/cabletv/purchase" payload := strings.NewReader("{\n \"product_type\": \"dstv\",\n \"smartcard_number\": \"1212121212\",\n \"package_code\": \"dstv-compact\",\n \"amount\": 19000,\n \"phone\": \"08012345678\",\n \"subscription_type\": \"renew\",\n \"request_ref\": \"b7e2f4a1-3d5c-4e6f-8a9b-0c1d2e3f4a5b\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.vtuagent.com/v1/cabletv/purchase") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"product_type\": \"dstv\",\n \"smartcard_number\": \"1212121212\",\n \"package_code\": \"dstv-compact\",\n \"amount\": 19000,\n \"phone\": \"08012345678\",\n \"subscription_type\": \"renew\",\n \"request_ref\": \"b7e2f4a1-3d5c-4e6f-8a9b-0c1d2e3f4a5b\"\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.vtuagent.com/v1/cabletv/purchase") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{\n \"product_type\": \"dstv\",\n \"smartcard_number\": \"1212121212\",\n \"package_code\": \"dstv-compact\",\n \"amount\": 19000,\n \"phone\": \"08012345678\",\n \"subscription_type\": \"renew\",\n \"request_ref\": \"b7e2f4a1-3d5c-4e6f-8a9b-0c1d2e3f4a5b\"\n}") .asString(); ``` ```php request('POST', 'https://api.vtuagent.com/v1/cabletv/purchase', [ 'body' => '{ "product_type": "dstv", "smartcard_number": "1212121212", "package_code": "dstv-compact", "amount": 19000, "phone": "08012345678", "subscription_type": "renew", "request_ref": "b7e2f4a1-3d5c-4e6f-8a9b-0c1d2e3f4a5b" }', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.vtuagent.com/v1/cabletv/purchase"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"product_type\": \"dstv\",\n \"smartcard_number\": \"1212121212\",\n \"package_code\": \"dstv-compact\",\n \"amount\": 19000,\n \"phone\": \"08012345678\",\n \"subscription_type\": \"renew\",\n \"request_ref\": \"b7e2f4a1-3d5c-4e6f-8a9b-0c1d2e3f4a5b\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "product_type": "dstv", "smartcard_number": "1212121212", "package_code": "dstv-compact", "amount": 19000, "phone": "08012345678", "subscription_type": "renew", "request_ref": "b7e2f4a1-3d5c-4e6f-8a9b-0c1d2e3f4a5b" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.vtuagent.com/v1/cabletv/purchase")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```