# AddPerlApi

- Module: [CommunityToolkit.Aspire.Hosting.Perl](/reference/api/go/communitytoolkit.aspire.hosting.perl.md)
- Version: `13.6.1`
- Kind: `method`
- Defined on: `DistributedApplicationBuilder`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/tree/d9c2addac6f527ef2e33712d290b84574b455a3b)

Adds a Perl API server resource (e.g., Mojolicious, Dancer2) to the application model. Passes the `daemon` subcommand so HTTP frameworks start a listener.

## Remarks

This method configures a Perl API script and passes the default API subcommand
(`daemon`) so frameworks such as Mojolicious start an HTTP server.
The working directory is set to `appDirectory` and all relative paths
(including `WithLocalLib` and cpanfile discovery) resolve against it.

## Definition

```go
func (DistributedApplicationBuilder) AddPerlApi(
    resourceName string,
    appDirectory string,
    scriptName string,
) PerlAppResource
```

## Parameters

- `resourceName` (`string`) -- The name of the resource.
- `appDirectory` (`string`) -- The path to the directory containing the Perl script. Resolved relative to the AppHost project directory; becomes the resource's working directory and the anchor for all relative path resolution (script path, `WithLocalLib`, cpanfile discovery).
- `scriptName` (`string`) -- The API script path, relative to `appDirectory`. Do not include the `appDirectory` prefix -- the script is resolved relative to `appDirectory` automatically.

## Returns

[`PerlAppResource`](/reference/api/go/communitytoolkit.aspire.hosting.perl/perlappresource.md) -- A reference to the `IResourceBuilder`.

Returns a handle; failures surface later via `Err()`.

## Applies to

- `DistributedApplicationBuilder`
