Comprehensive guide to using the NACHA File Generator API
The NACHA File Generator API provides a simple way to generate compliant NACHA formatted files for ACH (Automated Clearing House) transactions. These files are used by financial institutions to process electronic fund transfers.
This API handles all the complexities of NACHA file formatting, including fixed-width field formatting, batch and file header/footer generation, control total calculations, hash sum calculations, and record count tracking.
The API provides two main endpoints for generating and validating NACHA files.
Generates a compliant NACHA formatted file from the provided data.
Validates NACHA file data without generating a file.
{"valid": true, "message": "NACHA data validation successful"}
{"valid": false, "error": "NACHA validation failed", "details": [...]}
The API expects a JSON object with the following structure:
The file header record contains information about the origin and destination of the file.
Field | Required | Description | Format/Values |
---|---|---|---|
immediate_destination | Yes | Routing number of the ACH Operator or receiving point | 9 digits, can have a leading space |
immediate_origin | Yes | Routing number or other identifier of the originating institution | 9 digits, can have a leading space |
file_creation_date | No | Date the file was created | YYMMDD format (defaults to current date) |
file_creation_time | No | Time the file was created | HHMM format (defaults to current time) |
file_id_modifier | No | Distinguishes between multiple files created on same date | A-Z, 0-9 (defaults to 'A') |
record_size | No | Size of each record | 094 (default) |
blocking_factor | No | Number of records in a block | 10 (default) |
format_code | No | Format code | 1 (default) |
immediate_destination_name | No | Name of the destination institution | Up to 23 characters |
immediate_origin_name | No | Name of the originating institution | Up to 23 characters |
reference_code | No | Reference code for the file | Up to 8 characters |
Each batch header record contains information about a group of related entries.
Field | Required | Description | Format/Values |
---|---|---|---|
service_class_code | Yes | Code indicating the type of entries in the batch | 200, 220, or 225 |
company_name | Yes | Name of the company/organization | Up to 16 characters |
company_discretionary_data | No | For discretionary use | Up to 20 characters |
company_id | Yes | Company identification number | Up to 10 characters |
standard_entry_class | Yes | Code identifying the type of entries | PPD, CCD, CTX, etc. |
company_entry_description | Yes | Description of the entries | Up to 10 characters |
company_descriptive_date | No | Descriptive date for the company | YYMMDD format |
effective_entry_date | No | Date the entries should be settled | YYMMDD format |
settlement_date | No | Settlement date filled by ACH Operator | 3 characters |
originator_status_code | No | Code identifying the status of the originator | 1 (default) |
originating_dfi_id | Yes | Routing number of the originating institution | 9 digits |
batch_number | No | Batch sequence number | Up to 7 digits |
Each entry detail record contains information about an individual transaction.
Field | Required | Description | Format/Values |
---|---|---|---|
transaction_code | Yes | Code identifying the type of transaction | 22 (checking credit), 27 (checking debit), etc. |
receiving_dfi_id | Yes | Routing number of the receiving institution (including check digit) | 9 digits (complete routing number) |
dfi_account_number | Yes | Account number at the receiving institution | Up to 17 characters |
amount | Yes | Amount of the transaction in cents | Up to 10 digits (e.g., 100000 = $1,000.00) |
individual_id | No | Identification number for the individual | Up to 15 characters |
individual_name | Yes | Name of the individual | Up to 22 characters |
discretionary_data | No | For discretionary use | Up to 2 characters |
trace_number | No | Unique identifier for the transaction | Up to 15 digits |
addenda | No | Array of addenda records | See Addenda Records section |
Addenda records provide additional information related to an entry detail record.
Field | Required | Description | Format/Values |
---|---|---|---|
addenda_type_code | No | Type of addenda record | 05 (default) |
payment_related_info | Yes | Additional information about the payment | Up to 80 characters |
addenda_sequence_number | No | Sequence number for multiple addenda records | Up to 4 digits (defaults to 1) |
This example creates a simple NACHA file with one batch containing one entry:
This example creates a NACHA file with multiple batches and entries, including addenda records:
NACHA files consist of fixed-width records in a specific format. Each record is exactly 94 characters long. The file has a hierarchical structure:
The API automatically generates the control records based on the data provided. It also handles padding the file with "9" records to ensure the file contains a multiple of 10 records as required by the NACHA format.