Epicor REST API PowerShell Script Generator
Pulling data from Epicor into a CSV is a daily need for developers and admins. This generator builds a clean PowerShell script for the Kinetic REST API v2, with credentials kept out of the code.
Fill in
PowerShell script
# Epicor REST v2 query to CSV
# Store the API key and credentials outside the script (environment variables or a secret store).
$server = "erp.example.com"
$instance = "KineticLive"
$company = "EPIC06"
$apiKey = $env:EPICOR_API_KEY
$user = $env:EPICOR_USER
$pass = $env:EPICOR_PASS
$pair = "$($user):$($pass)"
$token = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes($pair))
$headers = @{
"Authorization" = "Basic $token"
"x-api-key" = $apiKey
"Accept" = "application/json"
}
$base = "https://$server/$instance/api/v2/odata/$company"
$query = '$select=PartNum,PartDescription,ClassID,IUM&$filter=InActive eq false&$top=100'
$uri ="$base/Erp.BO.PartSvc/Parts?" + $query
try {
$resp = Invoke-RestMethod -Uri $uri -Headers $headers -Method Get
$rows = $resp.value
Write-Host ("Rows returned: " + $rows.Count)
$rows | Export-Csv -Path "C:\Temp\parts.csv" -NoTypeInformation -Encoding UTF8
} catch {
Write-Error ("Epicor call failed: " + $_.Exception.Message)
exit 1
}Variant: run a BAQ instead
# Replace the URI line with a BAQ call. The BAQ must exist and be available to the REST user. # $uri = "$base/BaqSvc/YourBaqId/Data?" + '$top=100'
Check three things for your site. First, the URL path (instance and v2 odata pattern) and the authentication method, since some sites use token auth or a different gateway. Second, that the service and entity names exist in your release. Third, that your user has security for the service. Never commit API keys or passwords to source control. The OData options are kept in single quotes so PowerShell does not treat them as variables.
Want governed ERP data access for AI and reporting?
Optional: talk through a read-only access layer on your own infrastructure.
Optional. The tool and every export work without this. No spam.
How to use the generator
Enter your server name, instance, company and the business object service you want, for example Erp.BO.PartSvc with the Parts entity. Choose the fields to return, add an OData filter and set a row limit. The script reads the API key and credentials from environment variables, calls the endpoint with Invoke-RestMethod and writes the result to CSV. Copy the code, set the environment variables on the machine that runs it, and run it first with a small row limit.
- Set EPICOR_API_KEY, EPICOR_USER and EPICOR_PASS as environment variables
- Start with a top value of 10 or 100
- Confirm the service name in your REST help page
- Schedule only after a successful manual run
How the call is built
Epicor REST v2 exposes business objects through an OData style path that includes the company. Each request needs an authorization header and an API key header. Query options such as select, filter and top shape the response and reduce the load on the server. A BAQ can be called through the BAQ service with the BAQ ID, which is often the simplest way to return joined data. Responses contain a value array that PowerShell can pipe straight to Export-Csv.
Reading the result and paging
A successful call prints the number of rows and writes the CSV. If you need more rows than the server returns in one response, page with top and skip, and loop until fewer rows than the page size are returned. Keep pages moderate, such as a few thousand rows, to avoid timeouts. Check dates and decimals in the CSV, since Excel may reformat them when opened.
Common mistakes
Frequent problems are 401 errors from a missing API key header, 403 errors when the user lacks security for the service, and wrong paths from a different instance name. Another is hard coding passwords in the script. Use a secret store or protected environment variables, and use a dedicated integration user with minimum rights. Do not call write methods from a script before testing in a non production environment.
- 401 usually means credentials or API key headers are wrong
- 403 usually means missing security on the service
- 404 usually means a wrong instance or service name
- Never store secrets in the script
Frequently Asked Questions
How do I authenticate to the Epicor REST API from PowerShell?
Most sites send a Basic authorization header with the user name and password plus an x-api-key header. Some environments use token based authentication instead, so confirm the method with your Epicor administrator before building the script.
What is the difference between REST v1 and v2?
Version 2 offers an OData style interface with a company segment in the path and supports query options such as select, filter and top. Version 1 uses a different path pattern. Check which versions your instance exposes in the REST help page.
Can I call a BAQ from the REST API?
Yes. BAQs can be called through the BAQ service by passing the BAQ ID, and they return their result set as JSON. The BAQ must be published and your user must have access to it.
How do I avoid timeouts on large extracts?
Select only needed fields, filter on a date or key range, and page with top and skip. For very large extracts consider a BAQ or a scheduled export on the server side rather than one big REST call.
If you build many Epicor integrations and extracts, Netray can discuss a governed, read-only data layer or assistant that runs on your own infrastructure.
Related Tools
Epicor Table Reference: Erp.Part, Erp.JobHead, Erp.OrderHed
Searchable list of frequently used columns in three core Epicor tables, with type and usage notes for BAQs, reports and REST queries.
EpicorEpicor BAQ Calculated Field Examples Reference
A searchable cheat sheet of BAQ calculated field expressions you can copy into the Query Builder, grouped by dates, quantities, pricing and text.
EpicorEpicor Function Library Design Template
A design document for an Epicor function: signature, inputs, outputs, logic notes, security, test cases and sign off.
EpicorEpicor Customization Migration Estimator
Count your customizations, BPMs, reports and BAQs and get an hours and cost estimate for retesting and rework in an upgrade or Kinetic move.
More Epicor tools
See all- Epicor Kinetic Customization Change Request Form Template
- Epicor Kinetic Go-Live Cutover Plan Template
- Epicor Kinetic User Access Request Form Template
- Epicor Kinetic BPM Directive Inventory Worksheet
- Epicor Kinetic Scheduled Task Register Worksheet
- Epicor Kinetic Custom Report Inventory Worksheet
- Epicor Kinetic Data Migration Mapping Worksheet
- Epicor Kinetic Data Load Effort Calculator
- Epicor Business Object Services Reference
New to Epicor ERP? Start with the Epicor ERP guide and toolkit, or plan with Training Path Builder, ERP Certification Study Planner, Upgrade Path Planner.
Keep exploring
Free tools
- Epicor REST API v2 URL BuilderFill in server, instance, company and service to get a ready OData URL, a curl command and the required headers for the Epicor REST API v2.
- Epicor Kinetic Private AI Layer Blueprint GeneratorGenerate a shareable private AI architecture plan for Epicor Kinetic on-premises, with components, security controls, rollout phases and open questions for IT.
- Epicor UAT Test Script WorksheetAn editable UAT script for Epicor with expected results, tester, status and defect counts. Track pass rate and export to Excel.
ERP fixes and how-tos
- How to Add AI to Epicor Kinetic On-Premises Without Moving Your DataReference architecture for a private AI assistant on Epicor Kinetic on-premises: BAQ and REST v2 access, SQL replica, local LLM, roles, audit and rollout.
- Epicor Kinetic API Documentation: Where It Lives and How the URLs WorkWhere the Epicor Kinetic REST API documentation lives, the v1 and v2 URL patterns, how authentication works, and what to use instead of an SDK.
- Epicor REST API v2: OData Filter, Select and Expand ExamplesWorking Epicor Kinetic REST v2 OData examples: URL format, filter, select, top, expand, BAQ endpoints, the API key header and paging, with common error causes.
AI on your ERP
- Private AI for Epicor Kinetic Cloud, Outside the Multi-Tenant BoundaryRun a private LLM on Epicor Kinetic private cloud or Kinetic Cloud data via BAQs, REST v2 and Data Fabric, keeping sensitive manufacturing data off shared AI.
- AI for Epicor Kinetic, Beyond What Prism CoversAdd AI to Epicor Kinetic beyond Prism: private LLM over BAQs, BPM data, and REST v2, on-prem or private cloud, with honest guidance on when Prism already covers you.
Integrations
- How to add AI agents to Epicor KineticHow to add AI agents to Epicor Kinetic: a tool layer over the REST v2 API and BAQs, MRP exception triage, PO expediting, and human approval before any write.
- How to build an MCP server for Epicor KineticDesign a Model Context Protocol server for Epicor Kinetic: which read tools to expose, BAQ and REST v2 mapping, auth, stdio vs HTTP transport and audit logging.
Software
- Epicor KineticEpicor Kinetic explained for manufacturers: modules, REST API, BAQs, deployment, strengths, limits and alternatives to compare before choosing or upgrading.
- Epicor CPQEpicor CPQ is a cloud configure-price-quote product with visual 3D configuration for manufacturers. Modules, ERP integrations and alternatives explained.