> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apinizer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create API Proxy from File

> Creates an API proxy by parsing an OpenAPI (Swagger), WSDL specification from an uploaded file, or creates a reverse proxy. The API proxy can be automatically deployed to specified environments after creation. For WSDLs with many XSDs, use a ZIP file.

## Endpoint

```
POST /apiops/projects/{projectName}/apiProxies/file/
```

### Alternative Endpoint (PUT for update)

```
PUT /apiops/projects/{projectName}/apiProxies/file/
```

## Authentication

Requires a Personal API Access Token.

### Header

```
Authorization: Bearer YOUR_TOKEN
```

## Request

### Headers

| Header        | Value               | Required |
| ------------- | ------------------- | -------- |
| Authorization | Bearer {token}      | Yes      |
| Content-Type  | multipart/form-data | Yes      |

### Path Parameters

| Parameter   | Type   | Required | Description  |
| ----------- | ------ | -------- | ------------ |
| projectName | string | Yes      | Project name |

### Form Data

| Field    | Type          | Required | Description                                                                    |
| -------- | ------------- | -------- | ------------------------------------------------------------------------------ |
| metadata | string (JSON) | Yes      | JSON string containing API proxy metadata                                      |
| specFile | file          | Yes      | Specification file (OpenAPI/Swagger/WSDL) or ZIP file for WSDLs with many XSDs |

### Request Body (metadata JSON)

#### Full JSON Body Example

```json theme={null}
{
  "apiProxyName": "petstore-api",
  "apiProxyDescription": "Petstore API Proxy",
  "apiProxyCreationType": "OPEN_API",
  "clientRoute": {
    "relativePathList": ["/api/v1"],
    "hostList": ["api.example.com"],
    "methodList": ["GET", "POST", "PUT", "DELETE"],
    "headerList": [],
    "bufferRequest": true,
    "bufferResponse": true
  },
  "routingInfo": {
    "routingAddressList": [
      {
        "address": "https://backend.example.com",
        "weight": 100,
        "soapType": "SOAP11"
      }
    ],
    "loadBalanceAlgorithm": "ROUND_ROBIN",
    "connectTimeout": 30,
    "readTimeout": 60,
    "retryCount": 3,
    "failoverRetryCount": 2,
    "ignoreRoutingError": false
  },
  "deploy": false,
  "deployTargetEnvironmentNameList": ["production"],
  "reParse": false,
  "soapToRest": false,
  "enableWSA": false,
  "enableWSRM": false,
  "backendApiVersion": "v1",
  "maintenanceModeSetting": {
    "enabled": false,
    "httpStatusCode": 503,
    "contentType": "application/json",
    "message": "Service is under maintenance"
  }
}
```

#### Request Body Fields

| Field                           | Type    | Required | Default | Description                                            |
| ------------------------------- | ------- | -------- | ------- | ------------------------------------------------------ |
| apiProxyName                    | string  | Yes      | -       | API Proxy name (must be unique within project)         |
| apiProxyDescription             | string  | No       | -       | API Proxy description                                  |
| apiProxyCreationType            | string  | Yes      | -       | API creation type                                      |
| clientRoute                     | object  | Yes\*    | -       | Client route configuration (required if reParse=false) |
| routingInfo                     | object  | No       | -       | Routing configuration                                  |
| deploy                          | boolean | No       | false   | Whether to deploy after creation                       |
| deployTargetEnvironmentNameList | array   | No       | \[]     | List of environment names to deploy to                 |
| reParse                         | boolean | No       | false   | Whether to reparse existing API proxy (PUT only)       |
| soapToRest                      | boolean | No       | false   | Enable SOAP to REST transformation                     |
| enableWSA                       | boolean | No       | false   | Enable WS-Addressing (SOAP only)                       |
| enableWSRM                      | boolean | No       | false   | Enable WS-ReliableMessaging (SOAP only)                |
| backendApiVersion               | string  | No       | -       | Backend API version                                    |
| maintenanceModeSetting          | object  | No       | -       | Maintenance mode settings                              |

### EnumApiProxySpecType

* `OPEN_API` - OpenAPI 3.0 specification
* `SWAGGER` - Swagger 2.0 specification
* `WSDL` - WSDL specification (SOAP)
* `REVERSE_PROXY` - Reverse proxy (no spec file)

**Note:** For `REVERSE_PROXY`, `specFile` is not required.

#### clientRoute

| Field            | Type    | Required | Default | Description                                                            |
| ---------------- | ------- | -------- | ------- | ---------------------------------------------------------------------- |
| relativePathList | array   | Yes\*    | \[]     | List of relative paths (e.g., \["/api/v1"]). Required if reParse=false |
| hostList         | array   | No       | \[]     | List of virtual hosts (e.g., \["api.example.com"])                     |
| methodList       | array   | No       | \[]     | List of HTTP methods (e.g., \["GET", "POST"])                          |
| headerList       | array   | No       | \[]     | List of headers for routing                                            |
| bufferRequest    | boolean | No       | true    | Buffer request body                                                    |
| bufferResponse   | boolean | No       | true    | Buffer response body                                                   |

### EnumHttpRequestMethod

* `GET`, `POST`, `PUT`, `DELETE`, `PATCH`, `OPTIONS`, `HEAD`, `TRACE`, `ALL`

#### routingInfo

| Field                | Type    | Required | Default      | Description                   |
| -------------------- | ------- | -------- | ------------ | ----------------------------- |
| routingAddressList   | array   | No       | \[]          | List of backend addresses     |
| loadBalanceAlgorithm | string  | No       | ROUND\_ROBIN | Load balancing algorithm      |
| connectTimeout       | integer | No       | 30           | Connection timeout in seconds |
| readTimeout          | integer | No       | 60           | Read timeout in seconds       |
| retryCount           | integer | No       | 0            | Number of retries             |
| failoverRetryCount   | integer | No       | 0            | Number of failover retries    |
| ignoreRoutingError   | boolean | No       | false        | Ignore routing errors         |

### EnumRoutingAlgorithm

* `ROUND_ROBIN` - Round-robin load balancing
* `LRU` - Least recently used
* `WEIGHTED` - Weighted load balancing (requires weight in routingAddressList)
* `RANDOM` - Random selection
* `PICK_FIRST` - Pick first available

#### routingAddressList Item

| Field    | Type    | Required | Default | Description                                                       |
| -------- | ------- | -------- | ------- | ----------------------------------------------------------------- |
| address  | string  | Yes      | -       | Backend address URL                                               |
| weight   | integer | No\*     | 1       | Load balancing weight (required if loadBalanceAlgorithm=WEIGHTED) |
| soapType | string  | No\*     | SOAP11  | SOAP version (required if API type is SOAP)                       |

### EnumSoapApiPortType

* `SOAP11` - SOAP 1.1
* `SOAP12` - SOAP 1.2

#### maintenanceModeSetting

| Field          | Type    | Required | Default          | Description                           |
| -------------- | ------- | -------- | ---------------- | ------------------------------------- |
| enabled        | boolean | No       | false            | Enable maintenance mode               |
| httpStatusCode | integer | No       | 503              | HTTP status code for maintenance      |
| contentType    | string  | No       | application/json | Content type for maintenance response |
| message        | string  | No       | -                | Maintenance message                   |

## Response

### Success Response (200 OK)

```json theme={null}
{
  "success": true,
  "deploymentResult": {
    "success": true,
    "deploymentResults": [
      {
        "environmentName": "production",
        "success": true,
        "message": "Deployment successful"
      }
    ]
  }
}
```

#### Response Fields

| Field                              | Type    | Description                               |
| ---------------------------------- | ------- | ----------------------------------------- |
| success                            | boolean | Indicates if the request was successful   |
| deploymentResult                   | object  | Deployment result (if deploy=true)        |
| deploymentResult.success           | boolean | Overall deployment success                |
| deploymentResult.deploymentResults | array   | Individual environment deployment results |

### Error Response (400 Bad Request)

```json theme={null}
{
  "error": "bad_request",
  "error_description": "ApiProxy (name: petstore-api) is already exist!"
}
```

#### Common Causes

* API Proxy name already exists
* Invalid specification file format
* Invalid API creation type
* Missing required fields (clientRoute, specFile)
* Invalid file format

### Error Response (401 Unauthorized)

```json theme={null}
{
  "error": "unauthorized_client",
  "error_description": "Invalid token"
}
```

### Error Response (404 Not Found)

```json theme={null}
{
  "error": "not_found",
  "error_description": "Project (MyProject) is not found or user does not have privilege to access it!"
}
```

## cURL Example

### Example 1: Create REST API Proxy from OpenAPI File

```bash theme={null}
curl -X POST \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/file/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -F 'metadata={
    "apiProxyName": "petstore-api",
    "apiProxyDescription": "Petstore API Proxy",
    "apiProxyCreationType": "OPEN_API",
    "clientRoute": {
      "relativePathList": ["/api/v1"]
    },
    "deploy": false,
    "reParse": false,
    "soapToRest": false
  }' \
  -F "specFile=@openapi.json"
```

### Example 2: Create SOAP API Proxy from WSDL File

```bash theme={null}
curl -X POST \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/file/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -F 'metadata={
    "apiProxyName": "soap-service",
    "apiProxyDescription": "SOAP Web Service",
    "apiProxyCreationType": "WSDL",
    "clientRoute": {
      "relativePathList": ["/soap"]
    },
    "enableWSA": true,
    "enableWSRM": false,
    "deploy": false,
    "reParse": false
  }' \
  -F "specFile=@service.wsdl"
```

### Example 3: Create API Proxy with WSDL ZIP File

For WSDLs with many XSDs, use a ZIP file:

```bash theme={null}
curl -X POST \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/file/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -F 'metadata={
    "apiProxyName": "complex-soap-service",
    "apiProxyDescription": "Complex SOAP Service",
    "apiProxyCreationType": "WSDL",
    "clientRoute": {
      "relativePathList": ["/soap"]
    },
    "deploy": false,
    "reParse": false
  }' \
  -F "specFile=@wsdl-with-xsds.zip"
```

### Example 4: Update API Proxy (Reparse) using PUT

```bash theme={null}
curl -X PUT \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/file/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -F 'metadata={
    "apiProxyName": "petstore-api",
    "apiProxyDescription": "Updated Petstore API",
    "apiProxyCreationType": "OPEN_API",
    "reParse": true,
    "deploy": false
  }' \
  -F "specFile=@updated-openapi.json"
```

## Permissions

User must have **`API_MANAGEMENT` + `MANAGE`** permission in the project. For deployment operations (when `deploy: true` is set), user must also have **`API_MANAGEMENT` + `DEPLOY_UNDEPLOY`** permission.

## Notes and Warnings

* **File Format**: Supported formats: OpenAPI 3.0 (JSON/YAML), Swagger 2.0 (JSON/YAML), WSDL (XML)
* **ZIP Files**: For WSDLs with many XSDs, use a ZIP file containing all related files
* **Unique Names**: API Proxy names must be unique within a project
* **Reparse**: Use PUT endpoint with `reParse: true` to update an existing API proxy from a new specification file
* **Type Consistency**: When reparsing, the API creation type must match the original type
* **SOAP Features**: `enableWSA` and `enableWSRM` are only applicable for SOAP APIs
* **Reverse Proxy**: For reverse proxy, `specFile` is not required
* **Deployment**: If `deploy: true`, ensure environments exist and user has deployment permissions
* **License Limits**: Creating API proxies may be subject to license limits
* **File Size**: Large specification files may take longer to process

## Related Documentation

* [Create API Proxy from URL](/api-reference/api-proxies/crud/create-api-proxy-from-url) - Create from URL instead of file
* [List API Proxies](/api-reference/api-proxies/crud/list-api-proxies) - List all API proxies
* [Get API Proxy](/api-reference/api-proxies/crud/get-api-proxy) - Get API proxy details
* [Update API Proxy](/api-reference/api-proxies/crud/update-api-proxy) - Update API proxy
* [Delete API Proxy](/api-reference/api-proxies/crud/delete-api-proxy) - Delete API proxy
