C# Quickstart
The one-line version, for reference:
curl -X POST "https://api.labelzoom.com/api/v2/convert/zpl/to/pdf" -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: text/plain" -d '^XA^FO50,50^ADN,36,20^FDLabelZoom^FS^XZ' --output label.pdfThe same conversion with HttpClient (.NET 6+):
using System.Net.Http.Headers;
var zpl = "^XA^FO50,50^ADN,36,20^FDLabelZoom^FS^XZ";var apiKey = Environment.GetEnvironmentVariable("LABELZOOM_API_KEY");
using var client = new HttpClient();// The API key is optional — omit the Authorization header if it isn't set.if (!string.IsNullOrEmpty(apiKey)){ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);}
var content = new StringContent(zpl, System.Text.Encoding.UTF8, "text/plain");var response = await client.PostAsync( "https://api.labelzoom.com/api/v2/convert/zpl/to/pdf?label.width=4&label.height=6&dpi=203", content);
response.EnsureSuccessStatusCode();await File.WriteAllBytesAsync("label.pdf", await response.Content.ReadAsByteArrayAsync());Console.WriteLine("Wrote label.pdf");Converting a PDF to ZPL
Section titled “Converting a PDF to ZPL”var pdfBytes = await File.ReadAllBytesAsync("shipping-label.pdf");var pdfContent = new ByteArrayContent(pdfBytes);pdfContent.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
var response = await client.PostAsync( "https://api.labelzoom.com/api/v2/convert/pdf/to/zpl", pdfContent);response.EnsureSuccessStatusCode();var zpl = await response.Content.ReadAsStringAsync();In ASP.NET Core, register the client with IHttpClientFactory instead of newing it per request. All endpoint patterns and parameters: quickstart · Swagger reference.