Foreigners
Foreigners are the recognized citizens, residents or tenants of another state. Unrecognized citizens, residents or tenants of another state are simply outsiders. Foreigners are categorized in different ways and different states will have different laws and regulations defining the rights and responsibilities of different categories of foreigner.
Allied, Neutral or Hostile
Foreigners will generally be classified as belonging to either an allied, neutral or hostile state. Foreigners from allied states will generally have their status and station recognized, and in some cases will have certain of their native rights granted or at least protected by treaty. For example, foreign citizens of an allied state may be exempted from torture or the death penalty; should they commit a crime meriting such a punishment, they might instead be expelled to their home state (possibly in chains) and declared persona non grata. Similarly, a resident of an allied state - particularly one visiting for trade or business - would likely be permitted to create legally binding and enforceable contracts, as without them trade would not function.
Foreigners from neutral states may or may not have some or all of their rights granted temporarily on a case by case basis, but in most cases would need to petition for this, and have good reasons. A foreign resident merchant from a neutral state (ie: one that does not have explicit treaties with the state) would need to have pretty convincing arguments for why they should be permitted to conduct trade at all, and even if granted the right to do so temporarily, would likely have to pay very high tariffs.
Foreigners from hostile states will generally not be welcome, and if found inside the state without a visa will usually be considered spies, and be punished as such. That said 'hostile' does not necessarily mean 'at war'. A state may have an ongoing conflict with another state, and may therefore consider allies of that state to be hostile, while still conducting trade with them. In this case, foreigners from hostile states may be permitted, and may even continue to have some of their rights granted under tight constraint. Finally, foreign diplomats from hostile states will typically not only be granted many of their native rights, but will also usually be granted personal protection, even if being hosted by a state they are openly at war with.
Licensed or Itinerant
Foreign persons within a state will be either licensed, or itinerant. Licensed persons are imply those persons who have been granted explicit license to be in the state to and perform their work. This may be trade, diplomacy, service, labour, or any number of valid reasons. Generally, licensed foreign persons are permitted only to engage in a subset of the activities they may be permitted to engage in at home. For example, a foreign merchant who trades in fabrics and their raw materials would be permitted to enter the state, sell fabric, use the proceeds to purchase raw materials (such as raw hemp, cotton, or silk) and then return to their home with those materials. If, during their visit, they were to discover there was a large surplus of dye for sale, they may want to purchase some dye and bring it home, but this would technically not be permitted. They may choose to do so anyway (illegally), or they may choose to petition for a special permit, which they may or may not be granted depending on the context.
Itinerant persons are those who are 'just passing through'. Itinerant persons will still generally have their status and staion recognized, but aside from the minimal set of rights they need to simply traverse the state, they will not be permitted to perform their work; they cannot engage in trade, service or labour in exchange for payment. There are some exceptions to this, which may or may not be technically legal, but which are generally tolerated. Itinerant travellers may be permitted to engage in menial day labour in exchange for food and or lodging, but this is very strictly constained to unskilled labour: digging ditched, chopping wood, picking crops, loading and unloading, etc. Performing skilled trade work as a smith, a thatcher or a carpenter to help a resident farmer, for example, is strictly prohibited as this work is there to support the development of the companion tradespersons, and is reserved by law only to them.
Additionally, itinerant persons are generally allowed to freely engage in 'contracts against menace' - this means they are allowed to hunt and kill monsters, criminals, bandits or fugitives and to accept payment and to claim salvage rights while doing so. For example, a resident land owner and tenant farmers may have put a bounty on a hill giant that has been eating their sheep. Itinerant foreigners are free to attempt to claim the bounty by killing the hill giant, and will have rights to claim any loot the hill giant has been hoarding (in certain cases, rare, culturally important, or scientifically or magically significant treasures are exempted from these salvage rights and must be reported, though their discovery is usually rewarded).
Gaining Foreign Visas
In most cases, persons entering a foreign state must seek a visa - a document that grants them permission to enter and to excercise some subset of their rights. Major border crossings will usually have outposts for processing visas for visitors, but their normal process involves providing visas for the usual merchants they expect. Visitors seeking entry into a foreign state who are not regular visitors would be well advised to announce their impending arrival and intentions well in advance to avoid long delays (which could be many days depending on the individuals and states implicated). Gaining a visa to enter usually requires presenting official identification documentation and often also a passport. Gaining entery without identification means seeking a refugee visa, which is not something easily granted.