Assignment means the option buyer exercises and you are forced to fulfill the contract. If you sold a call, you sell shares. If you sold a put, you buy shares. It can happen before expiration.
Early assignment is rare but possible. It usually happens when an option is deep in the money and there is little extrinsic value left. The buyer has no reason to wait.
Dividends increase assignment risk on calls. If a stock pays a dividend, call holders might exercise early to capture it. If your short call is in the money before the ex-dividend date, you might get assigned.
Example: You sold a 50 call. Stock is at 55. Ex-dividend is tomorrow. The call has almost no extrinsic value. The buyer exercises to get the dividend. You wake up short 100 shares.
Short call assignment: You sell 100 shares at the strike price. If you owned the shares, they are gone. If you did not, you are now short shares.
Short put assignment: You buy 100 shares at the strike price. You need the cash or margin to cover the purchase.
Close before expiration. Do not hold short options into the final days if they are near the money.
Watch dividends. If you have a short call and ex-dividend is coming, close or roll before the date.
Check extrinsic value. If your short option has less than 0.10 in extrinsic value and is in the money, assignment risk is high.
If you are assigned on one leg of a spread, you still have the other leg. A short call assignment on a call spread means you are short shares, but you also have a long call. You can exercise the long call to cover, or buy shares in the market.
Example: You have a 50/55 call spread. You get assigned on the 50 call. You are short 100 shares. Your 55 call is still there. You can exercise it to buy shares at 55, or buy shares at market price.
Pin risk happens when the stock closes right at your short strike. You do not know if you will be assigned until after hours. This is another reason to close before expiration.