> For the complete documentation index, see [llms.txt](/llms.txt)

# GS2-StateMachine Transaction Actions

Specification of verify/consume/acquire transaction actions






## Acquire Action



### Gs2StateMachine:StartStateMachineByUserId

Start state machine by User ID

Starts a new state machine instance for the specified user using the latest master version. Arguments are passed as JSON and parsed into state machine variables. An optional TTL (in minutes) can be set; if omitted, the state machine remains valid for approximately 10 years.

**Quantity specification supported: NO**

**Reversible action: NO**

|  | Type | Condition | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128 chars | Namespace name<br>Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
| userId | string |  | ✓|  |  ~ 128 chars | User ID<br>Specify `#{userId}` to substitute the currently logged-in user's ID. |
| args | string |  | | "{}" |  ~ 4096 chars | Arguments to be passed to the state machine |
| ttl | int |  | |  | 1 ~ 525600 | Validity period (minutes) |
| timeOffsetToken | string |  | |  |  ~ 1024 chars | Time offset token |




**JSON**
```json
{
    "action": "Gs2StateMachine:StartStateMachineByUserId",
    "request": {
        "namespaceName": "[string]Namespace name",
        "userId": "[string]User ID",
        "args": "[string]Arguments to be passed to the state machine",
        "ttl": "[int]Validity period (minutes)",
        "timeOffsetToken": "[string]Time offset token"
    }
}
```

**YAML**
```yaml

action: Gs2StateMachine:StartStateMachineByUserId
request:
  namespaceName: "[string]Namespace name"
  userId: "[string]User ID"
  args: "[string]Arguments to be passed to the state machine"
  ttl: "[int]Validity period (minutes)"
  timeOffsetToken: "[string]Time offset token"
```

**GS2-Script**
```lua

transaction.service("stateMachine").acquire.start_state_machine_by_user_id({
    namespaceName="[string]Namespace name",
    userId="[string]User ID",
    args="[string]Arguments to be passed to the state machine",
    ttl="[int]Validity period (minutes)",
    timeOffsetToken="[string]Time offset token",
})
```


---



