{"record":{"id":"6f4af089e047f8af","repo":"jeessy2/ddns-go","slug":"vercel-api-returned-status-code-d","errorCode":null,"errorMessage":"Vercel API returned status code %d","messagePattern":"Vercel API returned status code (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dns/vercel.go","lineNumber":181,"sourceCode":"\n\treq, err := http.NewRequest(\n\t\tmethod,\n\t\tapi,\n\t\tbytes.NewBuffer(payload),\n\t)\n\tif err != nil {\n\t\treturn\n\t}\n\treq.Header.Set(\"Authorization\", \"Bearer \"+v.DNS.Secret)\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tclient := v.httpClient\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif resp.StatusCode != 200 {\n\t\treturn fmt.Errorf(\"Vercel API returned status code %d\", resp.StatusCode)\n\t}\n\tif result != nil {\n\t\terr = util.GetHTTPResponse(resp, err, result)\n\t}\n\treturn\n}\n","sourceCodeStart":163,"sourceCodeEnd":188,"githubUrl":"https://github.com/jeessy2/ddns-go/blob/5874c2e6667c69357ab95079421131104bd3fcae/dns/vercel.go#L163-L188","documentation":"Thrown by the Vercel DNS provider's request() helper (dns/vercel.go:181) whenever the Vercel API responds with a status code other than 200. The provider treats only 200 as success, so 4xx (bad token, invalid zone, wrong teamId) and 5xx (Vercel outage) both surface through this error. It is raised in listExistingRecords, createRecord and updateRecord. Unlike richer clients, it discards the response body, so the API's detailed reason is lost.","triggerScenarios":"GET/POST/PATCH/DELETE to api.vercel.com returning 401/403 (invalid or revoked Bearer token), 400 (bad record payload or domain name), 404 (domain not in account or wrong teamId), 429 (rate limit), or 5xx (Vercel incident).","commonSituations":"Stale Vercel access token after rotation; using an account token while the domain lives in a team (or ExtParam/TeamId misconfigured); typo in the domain name; Vercel API rate limiting during bulk updates; Vercel platform incidents.","solutions":["Verify the Vercel API token is valid and has access to the domain (vercel whoami / test with curl -H \"Authorization: Bearer ...\" https://api.vercel.com/v4/domains)","If the domain is in a team, set the teamId (ExtParam) correctly — an account-only token gets 403/404","Check the record payload: domain name, type and value must match what Vercel expects","If 429, back off and retry later; if 5xx, check Vercel status and retry"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Go: preflight token/team access before provider calls\nreq, _ := http.NewRequest(\"GET\", \"https://api.vercel.com/v9/projects\", nil)\nreq.Header.Set(\"Authorization\", \"Bearer \"+token)\nif teamID != \"\" {\n    q := req.URL.Query(); q.Set(\"teamId\", teamID); req.URL.RawQuery = q.Encode()\n}\nresp, err := http.DefaultClient.Do(req)\nif err != nil || resp.StatusCode != 200 {\n    return fmt.Errorf(\"Vercel token/teamId preflight failed: status %v\", err)\n}\nresp.Body.Close()","typeGuard":null,"tryCatchPattern":"// Go\nerr := provider.CreateRecord(rec)\nif err != nil {\n    if strings.Contains(err.Error(), \"Vercel API returned status code\") {\n        if strings.Contains(err.Error(), \"401\") || strings.Contains(err.Error(), \"403\") {\n            return fmt.Errorf(\"check Vercel token and teamId (ExtParam): %w\", err)\n        }\n        if strings.Contains(err.Error(), \"429\") || strings.Contains(err.Error(), \"5\") {\n            return retryWithBackoff(err)\n        }\n    }\n    return err\n}","preventionTips":["Verify the Bearer token is current and scoped to the right account/team","Always set teamId (ExtParam) when the domain belongs to a Vercel team","Respect rate limits — add backoff for bulk record updates","Check https://www.vercel-status.com when seeing 5xx"],"tags":["http","api-error","vercel","dns-provider"],"backgroundTag":"http-non-200-response","analyzedSha":"5874c2e6667c69357ab95079421131104bd3fcae","analyzedAt":"2026-09-03T15:41:16.799Z","contentChangedAt":"2026-09-03T15:41:16.799Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}