# Session.StartSession(var Integer, Integer, Text, var Record, Duration) Method
> Version: _Available or changed with runtime version 7.0._
Starts a session without a UI and runs the specified codeunit.
## Syntax
```al
[Ok := ]  Session.StartSession(var SessionId: Integer, CodeunitId: Integer, Company: Text, var Record: Record, Timeout: Duration)
```
> NOTE
> This method can be invoked without specifying the data type name.
## Parameters
SessionId
Type: ../integer/integer-data-type
The ID of the new session that is started. The ID is assigned to the SessionID variable after the session is started successfully. This parameter is passed by reference to the method.
CodeunitId
Type: ../integer/integer-data-type
The ID of the codeunit to run when the session is started.
Company
Type: ../text/text-data-type
The company in which to start the session. By default, the session is started in the same company as the calling session.
Record
Type: ../record/record-data-type
A record that is passed to the OnRun trigger of the codeunit that runs when the session is started. This parameter is optional.
Timeout
Type: ../duration/duration-data-type
Specifies the timeout of the created session. If not specified a default timeout will be used; for OnPrem, the default timeout is set on the server, for SaaS the current default timeout is 12 hours, and may change in the future.
## Return Value
*[Optional] Ok*
Type: ../boolean/boolean-data-type
true if the operation was successful; otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.
## Remarks
The session is started on the same Business Central instance from which the method is called. The session that is started is a background session and therefore has no UI. The session executes using the same user credentials as the calling AL code.
For information about how dialog boxes are handled in a background session, see session-startsession-integer-integer-string-table-method#dialog-box-behavior.
## Related information
session-data-type
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>
Configuring Business Central Server<../../../administration/configure-server-instance>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/session/session-startsession-integer-integer-string-table-duration-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/session/session-startsession-integer-integer-string-table-duration-method/
